//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.hustcad.plm.pdm.partbom.service.impl.batchimport;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.TimeInterval;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.googlecode.aviator.utils.ArrayHashMap;
import com.hustcad.plm.basic.log.LogEventEnum;
import com.hustcad.plm.basic.log.TyplmLogger;
import com.hustcad.plm.basic.util.TyplmEntityBaseUtil;
import com.hustcad.plm.basic.util.TyplmExceptionUtil;
import com.hustcad.plm.basic.util.TyplmLoggerUtil;
import com.hustcad.plm.caddocapi.constant.TyplmCadImportProgressEnum;
import com.hustcad.plm.caddocapi.service.TyplmCADBuildHistoryService;
import com.hustcad.plm.caddocapi.service.TyplmCADDescLinkService;
import com.hustcad.plm.caddocapi.service.TyplmCADRuleBuildService;
import com.hustcad.plm.caddocapi.service.batchimport.TyplmBatchImportBasicDataService;
import com.hustcad.plm.middle.caddoc.service.impl.batchimport.TyplmCadImportProgressUtils;
import com.hustcad.plm.middle.caddocapi.service.TyplmImportThreeDimService;
import com.hustcad.plm.pdm.access.model.dto.AccessBatchDTO;
import com.hustcad.plm.pdm.access.service.TyplmAccessJudgeService;
import com.hustcad.plm.pdm.access.service.TyplmEntityAdHocService;
import com.hustcad.plm.pdm.attribute.service.TyplmAttributeDefMapService;
import com.hustcad.plm.pdm.basedrule.dto.TyplmBaseRuleBoundedObjDTO;
import com.hustcad.plm.pdm.basedrule.service.TyplmBasedRuleService;
import com.hustcad.plm.pdm.caddoc.constant.CadConstant;
import com.hustcad.plm.pdm.caddoc.constant.CadPartLinkEnum;
import com.hustcad.plm.pdm.caddoc.model.dto.CadBuildHistoryDTO;
import com.hustcad.plm.pdm.caddoc.model.dto.CadBuildRuleDTO;
import com.hustcad.plm.pdm.caddoc.model.dto.ImportAttributeDTO;
import com.hustcad.plm.pdm.caddoc.model.dto.ImportCADDocOrPartDTO;
import com.hustcad.plm.pdm.caddoc.model.dto.ImportGlobeDTO;
import com.hustcad.plm.pdm.caddoc.model.dto.ImportStructDTO;
import com.hustcad.plm.pdm.caddoc.model.dto.ImportTransformDTO;
import com.hustcad.plm.pdm.caddoc.model.dto.ImportWorkSpaceDTO;
import com.hustcad.plm.pdm.caddoc.model.dto.ImportXmlDTO;
import com.hustcad.plm.pdm.caddoc.model.vo.CADWorkspaceVO;
import com.hustcad.plm.pdm.caddoc.model.vo.MDAImportOutDocVo;
import com.hustcad.plm.pdm.caddoc.model.vo.PdmCadBuildRuleVO;
import com.hustcad.plm.pdm.classification.model.dto.TyplmClassificationEntityDTO;
import com.hustcad.plm.pdm.classification.model.vo.TyplmClassificationEntityTreeVO;
import com.hustcad.plm.pdm.classification.service.TyplmClassificationService;
import com.hustcad.plm.pdm.common.model.dto.InsertClassificationType;
import com.hustcad.plm.pdm.common.service.entity.TyplmEntityBaseService;
import com.hustcad.plm.pdm.common.util.CommonUtil;
import com.hustcad.plm.pdm.common.util.TyplmPermissionsUtil;
import com.hustcad.plm.pdm.extension.service.iteration.TyplmCompanyVersionService;
import com.hustcad.plm.pdm.folder.model.dto.TyFolderPathDTO;
import com.hustcad.plm.pdm.folder.service.TyplmIterFolderMemberLinkService;
import com.hustcad.plm.pdm.framework.product.expansion.javabean.annotation.TyBugFix;
import com.hustcad.plm.pdm.iba.model.dto.SaveObjIBADTO;
import com.hustcad.plm.pdm.iba.service.TyplmAttributeValueService;
import com.hustcad.plm.pdm.iba.service.TyplmReferenceValueService;
import com.hustcad.plm.pdm.iteration.service.TyBranchidControlExtService;
import com.hustcad.plm.pdm.iteration.service.TyplmIteratorService;
import com.hustcad.plm.pdm.partbom.dto.TyPartImportBasicListDTO;
import com.hustcad.plm.pdm.partbom.dto.bom.TyplmCopyAttrParamDTO;
import com.hustcad.plm.pdm.partbom.dto.partalter.PartSubstituteCopyParamDTO;
import com.hustcad.plm.pdm.partbom.dto.partimport.PartImportBuildHistoryDTO;
import com.hustcad.plm.pdm.partbom.dto.partimport.PartImportIbaBeanDTO;
import com.hustcad.plm.pdm.partbom.dto.partimport.PartImportLogVO;
import com.hustcad.plm.pdm.partbom.dto.partimport.PartImportToDBDTO;
import com.hustcad.plm.pdm.partbom.dto.partimport.PartTypeRelDTO;
import com.hustcad.plm.pdm.partbom.dto.partimport.PartXmlAllNodeDTO;
import com.hustcad.plm.pdm.partbom.dto.partimport.PartXmlGlobeNodeDTO;
import com.hustcad.plm.pdm.partbom.dto.partimport.PartXmlNodeDTO;
import com.hustcad.plm.pdm.partbom.dto.partimport.PartXmlStructNodeDTO;
import com.hustcad.plm.pdm.partbom.enums.PartBomErrorCodeEnum;
import com.hustcad.plm.pdm.partbom.mapper.TyplmPartDescribeLinkBugFixMapper;
import com.hustcad.plm.pdm.partbom.mapper.TyplmPartUsageLinkMapper;
import com.hustcad.plm.pdm.partbom.service.TyplmPartBomService;
import com.hustcad.plm.pdm.partbom.service.TyplmPartDerivedImageService;
import com.hustcad.plm.pdm.partbom.service.TyplmPartDescribeLinkService;
import com.hustcad.plm.pdm.partbom.service.TyplmPartExtService;
import com.hustcad.plm.pdm.partbom.service.TyplmPartIteratorService;
import com.hustcad.plm.pdm.partbom.service.TyplmPartMasterExtService;
import com.hustcad.plm.pdm.partbom.service.TyplmPartQueryExtService;
import com.hustcad.plm.pdm.partbom.service.TyplmPartService;
import com.hustcad.plm.pdm.partbom.service.TyplmPartUsageLinkExtService;
import com.hustcad.plm.pdm.partbom.service.TyplmPartUsageLinkService;
import com.hustcad.plm.pdm.partbom.service.batchimport.TyplmPartBomImportService;
import com.hustcad.plm.pdm.partbom.service.bom.TyplmMPMBomService;
import com.hustcad.plm.pdm.partbom.service.partalter.TyplmPartSubstituteSaveService;
import com.hustcad.plm.pdm.partbom.service.view.TyplmViewDefService;
import com.hustcad.plm.pdm.partbom.util.excel.TyplmExcelDataCheckUtil;
import com.hustcad.plm.pdm.partbom.util.excel.TyplmExcelParseUtil;
import com.hustcad.plm.pdm.partbom.vo.MultiFactoryControlVO;
import com.hustcad.plm.pdm.partbom.vo.TyBuildObjVO;
import com.hustcad.plm.pdm.preference.service.TyPreferenceValueService;
import com.hustcad.plm.pdm.preference.util.TyplmPreferenceValueUtil;
import com.hustcad.plm.pdm.redislock.TyplmRedisLockService;
import com.hustcad.plm.pdm.series.model.dto.TySeriesOutDTO;
import com.hustcad.plm.pdm.type.service.TyplmTypeService;
import com.hustcad.plm.pdm.user.service.TyplmUserService;
import com.hustcad.plm.workspace.dto.WorkspaceOperateDTO;
import com.hustcad.plm.workspace.service.TyPlmDefaultWorkspaceService;
import com.hustcad.plm.workspace.service.TyplmSdkWorkspaceService;
import com.hustcad.plm.workspace.vo.WorkspaceMemberVO;
import com.jsyxdl.primary.service.PartTypeDefService;
import com.ty.basic.common.ITyCabined;
import com.ty.basic.common.ITyDomainAdministratored;
import com.ty.basic.constant.ContainerConstant;
import com.ty.basic.dto.AccessJudgeDTO;
import com.ty.basic.dto.CopyDTO;
import com.ty.basic.dto.ObjLinkCopyDTO;
import com.ty.basic.entity.CTyEntityBaseDO;
import com.ty.basic.entity.TyBaseObject;
import com.ty.basic.entity.cad.CADBuildHistoryDO;
import com.ty.basic.entity.cad.CADBuildRuleDO;
import com.ty.basic.entity.folder.IterFolderMemberLinkDO;
import com.ty.basic.entity.org.UserDO;
import com.ty.basic.entity.part.PartDO;
import com.ty.basic.entity.part.PartDescribeLinkDO;
import com.ty.basic.entity.part.PartMasterDO;
import com.ty.basic.entity.part.PartUsageLinkDO;
import com.ty.basic.entity.type.TypeDO;
import com.ty.basic.entity.view.ViewDefDO;
import com.ty.basic.handler.exceptionhandler.exception.ResponseCodeEnum;
import com.ty.basic.handler.exceptionhandler.exception.TyException;
import com.ty.basic.service.snow.SnowflakeIdComponent;
import com.ty.basic.session.TyAccountContext;
import com.ty.basic.util.EntityBaseUtil;
import com.ty.basic.util.ZTDateUtils;
import com.ty.basic.utils.BatchQueryHelper;
import com.ty.basic.utils.ConvertUtils;
import com.ty.basic.vo.AttributeVO;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.assertj.core.util.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.CollectionUtils;
import tk.mybatis.mapper.entity.Example;

@TyBugFix
public class TyplmPartBomImportBugFixServiceImpl extends TyplmPartBomImportServiceImpl implements TyplmPartBomImportService {
    private static final Logger log = LoggerFactory.getLogger(TyplmPartBomImportBugFixServiceImpl.class);
    private static PartDO partDONull = null;
    private static PartMasterDO partMasterDONull = null;
    @Resource
    private TyplmPartBomImportUtil typlmPartBomImportUtil;
    @Resource
    private TyplmPartBomImportCheckUtil typlmPartBomImportCheckUtil;
    @Resource
    private TyplmPartService typlmPartService;
    @Resource
    private TyplmPartQueryExtService typlmPartQueryExtService;
    @Resource
    private TyplmPartUsageLinkService typlmPartUsageLinkService;
    @Resource
    private TyplmViewDefService typlmViewDefService;
    @Resource
    private TyplmUserService typlmUserService;
    @Resource
    private TyBranchidControlExtService tyBranchidControlExtService;
    @Resource
    private SnowflakeIdComponent snowflakeIdComponent;
    @Resource
    private TyplmIterFolderMemberLinkService typlmIterFolderMemberLinkService;
    @Resource
    private TyplmAttributeValueService typlmAttributeValueService;
    @Resource
    private TyplmPartMasterExtService typlmPartMasterExtService;
    @Resource
    private TyplmPartExtService typlmPartExtService;
    @Resource
    private TyplmPartUsageLinkExtService typlmPartUsageLinkExtService;
    @Resource
    private TyplmMPMBomService typlmMPMBomService;
    @Resource
    private TyplmCADRuleBuildService typlmCadRuleBuildService;
    @Resource
    private TyplmIteratorService typlmIteratorService;
    @Resource
    private TyplmCADDescLinkService typlmCADDescLinkService;
    @Resource
    private TyplmCADBuildHistoryService typlmcadBuildHistoryService;
    @Resource
    private TyPlmDefaultWorkspaceService tyPlmDefaultWorkspaceService;
    @Resource
    private TyplmSdkWorkspaceService typlmSdkWorkspaceService;
    @Resource
    private TyplmEntityAdHocService typlmEntityAdHocService;
    @Resource
    private TyplmExcelParseUtil typlmExcelParseUtil;
    @Resource
    private TyplmPartUsageLinkMapper typlmPartUsageLinkMapper;
    @Resource
    private TyplmPartSubstituteSaveService typlmPartSubstituteSaveService;
    public static final List<String> EXCLUSION_CHANGE_NEW = Arrays.asList("buildRule-Att", "buildRule-Bom", "buildRule-PartAtt", "buildRule-AttBom", "buildRule-PartBom", "buildRule-All", "buildRule-Non", "buildRule-Part");
    @Resource
    private TyplmBatchImportBasicDataService typlmBatchImportBasicDataService;
    @Resource
    private TyplmPartBomImportService typlmPartBomImportService;
    @Resource
    private TyplmRedisLockService typlmRedisLockService;
    @Value("${cad.import.throw.exception:false}")
    private boolean cadThrowException;
    private static final String BRANCH_CACHE_PREFIX_KEY = "newBranchId_key";
    private static final String BRANCH_CACHE_PREFIX_KEY_SAVEASPART = "saveAsPart_key";
    private static final String BRANCH_CACHE_PREFIX_KEY_DOWNSTREAMPART = "downStreamPart_key";
    private static final String BRANCH_CACHE_PREFIX_KEY_SAVEASSTRUCT = "saveAsStruct_key";
    private static final String CHECK_IN = "check_in";
    private static final String SAVE_AS = "saveAs";
    private static final String HOLDER_PART_CLASSIFICATION_TREE = "TyplmPartBomImportService:partClassificationTree";
    private static final String HOLDER_PART_CLASSIFICATION_TREE_DISPLAY_NAME_MAP = "TyplmPartBomImportService:partClassificationTree:displayNameMap";
    private static final String HOLDER_PART_CLASSIFICATION_TREE_CLASS_PATH_MAP = "TyplmPartBomImportService:partClassificationTree:classPathMap";
    @Resource
    private TyplmExecutePartImportExtensionUtil typlmExecutePartImportExtensionUtil;
    @Resource
    private TyplmPartBomService typlmPartBomService;
    @Resource
    private TyplmTypeService typlmTypeService;
    @Resource
    private TyplmLogger typlmLogger;
    @Resource
    private TyplmPreferenceValueUtil typlmPreferenceValueUtil;
    @Value("${batchImportbom.not.childPart.readPermissions.isCreateBom: false}")
    private Boolean notChildPartReadPermissionsIsCreateBom;
    @Value("${batchimport.partbom.ignore.check.circularReference:false}")
    private Boolean ignoreCheckCircularReference;
    @Value("${batchImport.iba.count:50}")
    private int ibaCount;
    @Value("${query.PartNumber.count:100}")
    private int queryPartNumbercount;
    @Value("${part.checkout.copy.derivedImage:false}")
    private Boolean copyDerivedImage;
    @Value("${cad.import.part.view:Design}")
    private String cadImportPartView;
    @Resource
    private TyplmPartIteratorService typlmPartIteratorService;
    @Resource
    private TyplmReferenceValueService typlmReferenceValueService;
    @Resource
    private TyplmClassificationService typlmClassificationService;
    @Resource
    private TyplmBasedRuleService typlmBasedRuleService;
    @Resource
    private TyplmAccessJudgeService typlmAccessJudgeService;
    @Resource
    private TyplmImportThreeDimService typlmImportThreeDimService;
    @Resource
    private TyplmPartDerivedImageService typlmPartDerivedImageService;
    @Resource
    private TyplmCadImportProgressUtils progressUtils;
    @Resource
    private TyplmCompanyVersionService typlmCompanyVersionService;
    @Value("${batchImport.number:100}")
    private int count;
    @Value("${part.import.is.merge.structure:true}")
    private boolean isMergeStructure;
    @Value("${batchimport.partbom.history.updateBOM.not.upgrade.version:false}")
    private boolean notUpgradeVersion;
    @Resource
    private TyplmPartDescribeLinkService typlmPartDescribeLinkService;
    @Resource
    private TyplmEntityBaseService typlmEntityBaseService;
    @Resource
    private TyPreferenceValueService tyPreferenceValueService;
    @Resource
    private TyplmAttributeDefMapService typlmAttributeDefMapService;
    @Resource
    private TyplmPermissionsUtil typlmPermissionsUtil;
    @Resource
    private TyplmPartDescribeLinkBugFixMapper typlmPartDescribeLinkBugFixMapper;

    public TyplmPartBomImportBugFixServiceImpl() {
    }

    public Map<String, List<PartImportLogVO>> batchImportPartBomForSaveAs(UserDO userDO, PartXmlAllNodeDTO partXmlAllNodeDTO) {
        Map<String, List<PartImportLogVO>> returnLogMap = new HashMap();
        return (Map)(!ObjectUtils.isEmpty(partXmlAllNodeDTO) && !CollectionUtils.isEmpty(partXmlAllNodeDTO.getPartList()) ? this.importPartAndBom(userDO, partXmlAllNodeDTO, "saveAs", (Map)null) : returnLogMap);
    }

    public Map<String, List<PartImportLogVO>> batchImportPartBom(String standXMLInnerXML, BigInteger userOid) {
        long startTime = System.currentTimeMillis();
        UserDO userDO = CommonUtil.getUser();
        if (Objects.isNull(userDO)) {
            userDO = this.typlmUserService.selectByOid(userOid);
        }

        PartXmlAllNodeDTO partXmlAllNodeDTO = this.typlmPartBomImportUtil.xml2Object(standXMLInnerXML);
        if (Objects.isNull(partXmlAllNodeDTO)) {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_COMMON_XML_ERROR, new String[]{"XML conversion exception！"})));
        } else if (!CollectionUtils.isEmpty(partXmlAllNodeDTO.getPartList()) && !Objects.isNull(partXmlAllNodeDTO.getGlobe())) {
            if (StringUtils.isEmpty(partXmlAllNodeDTO.getGlobe().getPartLinkType())) {
                partXmlAllNodeDTO.getGlobe().setPartLinkType("buildRule-All");
            }

            Map<String, List<PartImportLogVO>> returnLogMap = this.importPartAndBom(userDO, partXmlAllNodeDTO, "false", (Map)null);
            long endTime = System.currentTimeMillis();
            TyplmLoggerUtil.debug(log, () -> {
                return "batchImportPartBom ==> 批量导入耗费时间=【{}】 ms";
            }, () -> {
                return new Object[]{endTime - startTime};
            });
            return returnLogMap;
        } else {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_PARAMETER_ERROR, new String[]{"partlist or globe is null！"})));
        }
    }

    public Map<String, List<PartImportLogVO>> batchImportPartBomForCAD(UserDO userDO, List<MDAImportOutDocVo> cadDocList, ImportXmlDTO importXmlDTO) {
        this.progressUtils.saveProgressInfo(this.progressUtils.buildProgressEnum(importXmlDTO.getProgressBarId(), "开始处理零部件信息"));
        Map<String, List<PartImportLogVO>> returnLogMap = new HashMap();
        if (!ObjectUtils.isEmpty(importXmlDTO) && !CollectionUtils.isEmpty(importXmlDTO.getPartList())) {
            Map<String, MDAImportOutDocVo> docXmlIdMap = new HashMap();
            this.progressUtils.saveProgressInfo(this.progressUtils.buildProgressEnum(importXmlDTO.getProgressBarId(), "根据图纸转换零部件处理格式。"));
            PartXmlAllNodeDTO partXmlAllNodeDTO = this.buildPartXmlNode(importXmlDTO, cadDocList, docXmlIdMap);
            this.progressUtils.saveProgressInfo(this.progressUtils.buildProgressEnum(importXmlDTO.getProgressBarId(), "零部件处理格式转换完成"));
            Map<String, List<PartImportLogVO>> returnMap = this.importPartAndBom(userDO, partXmlAllNodeDTO, "true", docXmlIdMap);
            this.progressUtils.saveProgressInfo(this.progressUtils.buildProgressEnum(importXmlDTO.getProgressBarId(), "零部件信息处理完成"));
            this.progressUtils.saveProgressInfo(new TyplmCadImportProgressEnum(partXmlAllNodeDTO.getProgressBarId(), "========================================================================================================================"));
            return returnMap;
        } else {
            return returnLogMap;
        }
    }

    private PartXmlAllNodeDTO buildPartXmlNode(ImportXmlDTO importXmlDTO, List<MDAImportOutDocVo> cadDocList, Map<String, MDAImportOutDocVo> docXmlIdMap) {
        PartXmlAllNodeDTO partXmlAllNodeDTO = new PartXmlAllNodeDTO();
        if (ObjectUtils.isEmpty(importXmlDTO)) {
            return partXmlAllNodeDTO;
        } else {
            partXmlAllNodeDTO.setProgressBarId(importXmlDTO.getProgressBarId());
            ImportGlobeDTO globe = importXmlDTO.getGlobe();
            ImportWorkSpaceDTO workSpace = importXmlDTO.getWorkSpace();
            String view = this.cadImportPartView;
            PartXmlGlobeNodeDTO globeDTO = new PartXmlGlobeNodeDTO();
            globeDTO.setView(view);
            globeDTO.setCopydesc("Y");
            globeDTO.setCopyref("Y");
            if (CollUtil.isNotEmpty(importXmlDTO.getPartList())) {
                ImportCADDocOrPartDTO importCADDocOrPartDTO = (ImportCADDocOrPartDTO)importXmlDTO.getPartList().get(0);
                if (ObjectUtils.isNotEmpty(importCADDocOrPartDTO)) {
                    globeDTO.setSystem(importCADDocOrPartDTO.getSystem());
                }
            }

            globeDTO.setAutocheckin("N");
            if ("buildRule".equalsIgnoreCase(globe.getOpeFlag())) {
                globeDTO.setPartLinkType("buildRule-All");
            } else {
                globeDTO.setPartLinkType(globe.getOpeFlag());
            }

            if (!CadConstant.getBuildruleStrategy().containsKey(globeDTO.getPartLinkType())) {
                throw PartBomErrorCodeEnum.BOM_IMPORT_FAILED_PARTDOCLINK_ERROR.getException(new Object[]{globeDTO.getPartLinkType(), CadConstant.getBuildruleStrategy().keySet().toString()});
            } else {
                partXmlAllNodeDTO.setGlobe(globeDTO);
                partXmlAllNodeDTO.setWorkSpace(workSpace);
                List<PartXmlNodeDTO> partList = this.getPartXmlNodeDTOS(importXmlDTO, view);
                partXmlAllNodeDTO.setPartList(partList);
                List<PartXmlStructNodeDTO> partStruct = this.getPartXmlStructNodeDTOS(importXmlDTO);
                partXmlAllNodeDTO.setPartStruct(partStruct);
                partXmlAllNodeDTO.setDocPartStruct(importXmlDTO.getDocPartStruct());
                Map<String, MDAImportOutDocVo> codeOidMap = new HashMap();
                if (!CollectionUtils.isEmpty(cadDocList)) {
                    cadDocList.forEach((cadDoc) -> {
                        MDAImportOutDocVo var10000 = (MDAImportOutDocVo)codeOidMap.put(cadDoc.getCode(), cadDoc);
                    });
                    importXmlDTO.getDocList().forEach((doc) -> {
                        if (CollUtil.isNotEmpty(doc.getAttributes())) {
                            doc.getAttributes().forEach((attr) -> {
                                if ("code".equalsIgnoreCase(attr.getAttributeKey())) {
                                    docXmlIdMap.put(doc.getId(), codeOidMap.get(attr.getAttributeValue()));
                                }

                            });
                        }

                    });
                }

                return partXmlAllNodeDTO;
            }
        }
    }

    private List<PartXmlStructNodeDTO> getPartXmlStructNodeDTOS(ImportXmlDTO importXmlDTO) {
        List<PartXmlStructNodeDTO> partStruct = new ArrayList();
        if (CollectionUtils.isEmpty(importXmlDTO.getPartStruct())) {
            return partStruct;
        } else {
            Iterator var3 = importXmlDTO.getPartStruct().iterator();

            while(var3.hasNext()) {
                ImportStructDTO structDTO = (ImportStructDTO)var3.next();
                if ("2".equalsIgnoreCase(structDTO.getDeptype())) {
                    List<PartXmlStructNodeDTO> filterStruct = (List)partStruct.stream().filter((struct) -> {
                        return structDTO.getParentId().equalsIgnoreCase(struct.getParentId()) && structDTO.getChildId().equalsIgnoreCase(struct.getChildId());
                    }).collect(Collectors.toList());
                    if (CollectionUtils.isEmpty(filterStruct)) {
                        this.addPartStructNode(partStruct, structDTO);
                    } else if (this.isMergeStructure) {
                        PartXmlStructNodeDTO xmlStruct = (PartXmlStructNodeDTO)filterStruct.get(0);
                        Double number = Double.valueOf(this.getNumber(structDTO, xmlStruct));
                        xmlStruct.setNumber(String.valueOf(number));
                        String currentLocation = structDTO.getLocationNumber();
                        String location = "";
                        if (StringUtils.isNotEmpty(currentLocation)) {
                            location = xmlStruct.getLocationNumber() + ',' + currentLocation;
                        }

                        xmlStruct.setLocationNumber(location);
                        List<ImportTransformDTO> transforms = ((PartXmlStructNodeDTO)filterStruct.get(0)).getTransforms();
                        if (ObjectUtils.isNotEmpty(structDTO.getTransform()) && Objects.nonNull(transforms)) {
                            transforms.add(structDTO.getTransform());
                        }

                        List<ImportAttributeDTO> attributes = ((PartXmlStructNodeDTO)filterStruct.get(0)).getAttributes();
                        if (CollUtil.isNotEmpty(attributes)) {
                            this.addStructAttrs(structDTO, attributes);
                        }
                    } else {
                        this.addPartStructNode(partStruct, structDTO);
                    }
                }
            }

            return partStruct;
        }
    }

    private String getNumber(ImportStructDTO structDTO, PartXmlStructNodeDTO xmlStruct) {
        double oldNumber = 1.0;
        if (ObjectUtils.isNotEmpty(xmlStruct.getNumber())) {
            oldNumber = Double.parseDouble(xmlStruct.getNumber());
        }

        double newerNumber = 1.0;
        if (ObjectUtils.isNotEmpty(structDTO.getNumber())) {
            newerNumber = Double.parseDouble(structDTO.getNumber());
        }

        double result = oldNumber + newerNumber;
        DecimalFormat df = new DecimalFormat("#.##");
        return df.format(result);
    }

    private void addPartStructNode(List<PartXmlStructNodeDTO> partStruct, ImportStructDTO structDTO) {
        PartXmlStructNodeDTO partXmlStructNodeDTO = new PartXmlStructNodeDTO();
        partXmlStructNodeDTO.setNumber(StringUtils.isEmpty(structDTO.getNumber()) ? "1" : structDTO.getNumber());
        partXmlStructNodeDTO.setChildId(structDTO.getChildId());
        partXmlStructNodeDTO.setParentId(structDTO.getParentId());
        partXmlStructNodeDTO.setLocationNumber(structDTO.getLocationNumber());
        if (StringUtils.isNotBlank(structDTO.getChildOrder())) {
            partXmlStructNodeDTO.setLineNumer(structDTO.getChildOrder());
        }

        List<ImportTransformDTO> transforms = new ArrayList();
        transforms.add(structDTO.getTransform());
        partXmlStructNodeDTO.setTransforms(transforms);
        partXmlStructNodeDTO.setAttributes(structDTO.getAttributes());
        partStruct.add(partXmlStructNodeDTO);
    }

    private void addStructAttrs(ImportStructDTO structDTO, List<ImportAttributeDTO> attributes) {
        if (!CollUtil.isEmpty(structDTO.getAttributes())) {
            structDTO.getAttributes().forEach((structAttr) -> {
                AtomicInteger countInteger = new AtomicInteger();
                attributes.forEach((attr) -> {
                    String attributeKey = attr.getAttributeKey();
                    String attributeValue = attr.getAttributeValue();
                    if (StringUtils.isNotEmpty(attributeKey) && attributeKey.equalsIgnoreCase(structAttr.getAttributeKey())) {
                        countInteger.getAndIncrement();
                        if (StringUtils.isNotEmpty(attributeValue) && !attributeValue.equalsIgnoreCase(structAttr.getAttributeValue())) {
                            attr.setAttributeValue(attributeValue + ";" + structAttr.getAttributeValue());
                        }
                    }

                });
                if (countInteger.intValue() <= 0) {
                    attributes.add(structAttr);
                }

            });
        }
    }

    private List<PartXmlNodeDTO> getPartXmlNodeDTOS(ImportXmlDTO importXmlDTO, String view) {
        List<PartXmlNodeDTO> partList = new ArrayList();
        if (CollectionUtils.isEmpty(importXmlDTO.getPartList())) {
            return partList;
        } else {
            importXmlDTO.getPartList().forEach((part) -> {
                PartXmlNodeDTO partXmlNodeDTO = new PartXmlNodeDTO();
                partXmlNodeDTO.setSubfolderid(part.getSubFolder());
                partXmlNodeDTO.setParttype(part.getPartType());
                partXmlNodeDTO.setParttypedefname(part.getPartType());
                partXmlNodeDTO.setPartname(part.getDlgName());
                partXmlNodeDTO.setPartnumber(part.getDlgGuid());
                partXmlNodeDTO.setSource(part.getSource());
                partXmlNodeDTO.setDefaultunit(part.getDefaultunit());
                partXmlNodeDTO.setSecurity(part.getSecuritylabels());
                partXmlNodeDTO.setView(view);
                partXmlNodeDTO.setId(part.getId());
                partXmlNodeDTO.setFamilyTableStatus(part.getFamilyTableStatus());
                if (StringUtils.isEmpty(part.getOpType())) {
                    partXmlNodeDTO.setOptype("ref");
                }

                if ("AutoCAD_CAD".equalsIgnoreCase(part.getSystem()) && !"ref".equalsIgnoreCase(partXmlNodeDTO.getOptype())) {
                    long docCount = importXmlDTO.getDocPartStruct().stream().filter((struct) -> {
                        return part.getId().equalsIgnoreCase(struct.getParentId());
                    }).count();
                    if (docCount <= 0L) {
                        partXmlNodeDTO.setOptype("dwgpart");
                    }
                }

                List<ImportAttributeDTO> attributes = part.getAttributes();
                partXmlNodeDTO.setAttributes(attributes);
                partList.add(partXmlNodeDTO);
            });
            return partList;
        }
    }

    private Map<String, List<PartImportLogVO>> initLogMap() {
        Map<String, List<PartImportLogVO>> returnLogMap = new HashMap();
        List<PartImportLogVO> errList = new ArrayList();
        List<PartImportLogVO> logList = new ArrayList();
        returnLogMap.put("errorLog", errList);
        returnLogMap.put("normalLog", logList);
        return returnLogMap;
    }

    private void setImportStrategy(String strategy, TyPartImportBasicListDTO tyPartImportBasicListDTO) {
        if (StringUtils.isNotBlank(strategy) && CadConstant.getBuildruleStrategy().containsKey(strategy)) {
            String strategyValue = (String)CadConstant.getBuildruleStrategy().get(strategy);
            boolean whetherCreatePart = this.getStrategyValue(strategyValue, 0);
            boolean whetherUpdatePart = this.getStrategyValue(strategyValue, 1);
            boolean whetherUpdateBom = this.getStrategyValue(strategyValue, 2);
            tyPartImportBasicListDTO.setCreatePart(whetherCreatePart);
            tyPartImportBasicListDTO.setUpdatePart(whetherUpdatePart);
            tyPartImportBasicListDTO.setUpdateBom(whetherUpdateBom);
        }

    }

    private boolean getStrategyValue(String strategyValue, int index) {
        char indexChar = 0;

        for(int i = 0; i < strategyValue.length(); ++i) {
            if (i == index) {
                indexChar = strategyValue.charAt(i);
                break;
            }
        }

        return indexChar == '1';
    }

    private void addViewToList(PartXmlNodeDTO partXmlNodeDTO, PartXmlGlobeNodeDTO globeNodeDTO, List<String> viewNameList) {
        if (StringUtils.isEmpty(partXmlNodeDTO.getView())) {
            partXmlNodeDTO.setView(globeNodeDTO.getView());
            this.typlmPartBomImportCheckUtil.addStringToList(globeNodeDTO.getView(), viewNameList);
        } else {
            this.typlmPartBomImportCheckUtil.addStringToList(partXmlNodeDTO.getView(), viewNameList);
        }

    }

    private void convertVariationByName(PartXmlNodeDTO partXmlNodeDTO, List<MultiFactoryControlVO> multiFactoryControlVOS) {
        if (!CollUtil.isEmpty(multiFactoryControlVOS)) {
            String variation1 = partXmlNodeDTO.getVariation1();
            String variation2 = partXmlNodeDTO.getVariation2();
            MultiFactoryControlVO multiFactoryControlVO = (MultiFactoryControlVO)multiFactoryControlVOS.get(0);
            Map<String, Map<String, String>> enumItemsMap = multiFactoryControlVO.getEnumItemsMap();
            Map<String, String> purposeOfBomMap = (Map)enumItemsMap.get("PurposeOfBOM");
            Map<String, String> spareBomMap = (Map)enumItemsMap.get("SpareBOM");
            Iterator var9;
            Map.Entry mapEntry;
            if (Boolean.TRUE.equals(multiFactoryControlVO.getShowBomPurpose()) && StringUtils.isNotEmpty(variation1)) {
                var9 = purposeOfBomMap.entrySet().iterator();

                label57:
                while(true) {
                    do {
                        do {
                            if (!var9.hasNext()) {
                                break label57;
                            }

                            mapEntry = (Map.Entry)var9.next();
                        } while(!StringUtils.isNotEmpty(variation1));
                    } while(!variation1.equalsIgnoreCase((String)mapEntry.getValue()) && !variation1.equalsIgnoreCase((String)mapEntry.getKey()));

                    partXmlNodeDTO.setVariation1((String)mapEntry.getKey());
                }
            }

            if (Boolean.TRUE.equals(multiFactoryControlVO.getShowSpareBom()) && StringUtils.isNotEmpty(variation2)) {
                var9 = spareBomMap.entrySet().iterator();

                while(true) {
                    do {
                        do {
                            if (!var9.hasNext()) {
                                return;
                            }

                            mapEntry = (Map.Entry)var9.next();
                        } while(!StringUtils.isNotEmpty(variation2));
                    } while(!variation2.equalsIgnoreCase((String)mapEntry.getValue()) && !variation2.equalsIgnoreCase((String)mapEntry.getKey()));

                    partXmlNodeDTO.setVariation2((String)mapEntry.getKey());
                }
            }
        }
    }

    private void addNumberToList(PartXmlNodeDTO partXmlNodeDTO, PartXmlGlobeNodeDTO globeNodeDTO, Map<String, List<String>> viewPartNumbersMap, Map<String, PartXmlNodeDTO> partNumberMap) {
        String partNumber = partXmlNodeDTO.getPartnumber();
        partNumberMap.put(partNumber, partXmlNodeDTO);
        if (StringUtils.isEmpty(partXmlNodeDTO.getView())) {
            partXmlNodeDTO.setView(globeNodeDTO.getView());
        }

        String viewVariationStr = partXmlNodeDTO.getView() + "@" + (String)StringUtils.defaultIfEmpty(partXmlNodeDTO.getVariation1(), "") + "@" + (String)StringUtils.defaultIfEmpty(partXmlNodeDTO.getVariation2(), "");
        List<String> partNumberList = (List)viewPartNumbersMap.get(viewVariationStr);
        if (CollectionUtils.isEmpty((Collection)partNumberList)) {
            partNumberList = new ArrayList();
        }

        if (StringUtils.isNotEmpty(partNumber)) {
            ((List)partNumberList).add(partNumber);
        }

        if ("saveAs".equalsIgnoreCase(globeNodeDTO.getIsCadImport()) || !"ref".equals(partXmlNodeDTO.getOptype())) {
            viewPartNumbersMap.put(viewVariationStr, partNumberList);
        }

    }

    private String getVariation(String viewVariationStr, int index) {
        String value = "";
        if (viewVariationStr.contains("@")) {
            String[] viewVariationArray = viewVariationStr.split("@");
            if (viewVariationArray.length > index) {
                value = viewVariationArray[index];
            }
        }

        return value;
    }

    private TyPartImportBasicListDTO queryAllPartByNumbers(List<PartXmlNodeDTO> partXmlNodeDTOS, PartXmlGlobeNodeDTO globeNodeDTO, UserDO userDO, List<Map<ResponseCodeEnum, String[]>> exceptions) {
        TyPartImportBasicListDTO basicListDTO = new TyPartImportBasicListDTO();
        this.setImportStrategy(globeNodeDTO.getPartLinkType(), basicListDTO);
        Map<String, List<String>> viewPartNumbersMap = new HashMap();
        Map<String, PartXmlNodeDTO> partNumberMap = new HashMap();
        Map<String, String> idNumberMap = new HashMap();
        List<String> viewList = new ArrayList();
        List<ViewDefDO> viewDefDOList = this.typlmViewDefService.queryAllView();
        Map<String, ViewDefDO> viewDefDOMap = new HashMap();
        if (CollUtil.isNotEmpty(viewDefDOList)) {
            viewDefDOMap = (Map)viewDefDOList.stream().collect(Collectors.toMap(ViewDefDO::getName, Function.identity(), (oldValue, newValue) -> {
                return oldValue;
            }));
        }

        if (CollUtil.isNotEmpty(partXmlNodeDTOS)) {
            Map<String, ViewDefDO> finalViewDefDOMap = viewDefDOMap;
            partXmlNodeDTOS.forEach((partNodeDto) -> {
                String viewName = partNodeDto.getView();
                if (StringUtils.isBlank(viewName)) {
                    viewName = globeNodeDTO.getView();
                }

                if (CollUtil.isNotEmpty(finalViewDefDOMap)) {
                    ViewDefDO viewDefDO = (ViewDefDO) finalViewDefDOMap.get(viewName);
                    if (viewDefDO == null) {
                        TyplmExceptionUtil.addExceptions(ResponseCodeEnum.BIZ_VIEW_NOTFOUND_WITH_NUMBER, new String[]{partNodeDto.getPartnumber() + "," + partNodeDto.getPartname(), partNodeDto.getView()}, exceptions);
                    }
                }

                partNodeDto.setPartnumber((String)Optional.ofNullable(partNodeDto.getPartnumber()).map(String::trim).orElse(null));
                partNodeDto.setGenerictype((String)Optional.ofNullable(partNodeDto.getGenerictype()).orElse("否"));
                partNodeDto.setVariation1((String)StringUtils.defaultIfBlank(partNodeDto.getVariation1(), (CharSequence)null));
                partNodeDto.setVariation2((String)StringUtils.defaultIfBlank(partNodeDto.getVariation2(), (CharSequence)null));
                String view = (String)Optional.ofNullable(partNodeDto.getView()).orElse(globeNodeDTO.getView());
                partNodeDto.setView(view);
                this.typlmPartBomImportCheckUtil.addStringToList(view, viewList);
                this.addViewToList(partNodeDto, globeNodeDTO, viewList);
            });
        }

        String strViewname = StringUtils.join(viewList, ",");
        List<MultiFactoryControlVO> multiFactoryControlVOS = this.typlmPartBomService.multiFactoryDisplayControl(strViewname);
        Map<String, List<MultiFactoryControlVO>> viewMultiFactoryControlMap = (Map)multiFactoryControlVOS.stream().collect(Collectors.groupingBy(MultiFactoryControlVO::getViewName));
        basicListDTO.setViewMultiFactoryControlMap(viewMultiFactoryControlMap);
        partXmlNodeDTOS.forEach((partNodeDto) -> {
            this.convertVariationByName(partNodeDto, multiFactoryControlVOS);
            this.addNumberToList(partNodeDto, globeNodeDTO, viewPartNumbersMap, partNumberMap);
            idNumberMap.put(partNodeDto.getId(), partNodeDto.getPartnumber());
        });
        Map<String, ViewDefDO> allViewDefDOMap = new HashMap();
        Map<BigInteger, PartDO> allUpdatePartDOMap = new HashMap();
        Map<String, BigInteger> allNewPartViewNumberOidMap = new HashMap();
        Map<String, PartMasterDO> allMasterDOMap = new HashMap();
        List<String> allMasterNumber = new ArrayList(partNumberMap.keySet());
        Collection<String> allNewMasterNumerList = this.batchQueryMasterDOByNumbers(allMasterNumber, allMasterDOMap);
        Iterator var21 = viewPartNumbersMap.entrySet().iterator();

        while(var21.hasNext()) {
            Map.Entry<String, List<String>> entry = (Map.Entry)var21.next();
            String viewVariationStr = (String)entry.getKey();
            String view = this.getVariation(viewVariationStr, 0);
            String variation1 = this.getVariation(viewVariationStr, 1);
            String variation2 = this.getVariation(viewVariationStr, 2);
            List<String> partNumbers = (List)entry.getValue();
            Map<String, PartMasterDO> masterDOMap = this.getViewMasterDo(allMasterDOMap, partNumbers);
            ViewDefDO viewDefDO = (ViewDefDO)((Map)viewDefDOMap).get(view);
            if (viewDefDO != null) {
                allViewDefDOMap.put(view, viewDefDO);
                Map<String, BigInteger> newPartViewNumberOidMap = new HashMap();
                List<MultiFactoryControlVO> controlVOS = (List)viewMultiFactoryControlMap.get(viewDefDO.getName());
                if (CollUtil.isNotEmpty(controlVOS) && !"saveAs".equalsIgnoreCase(globeNodeDTO.getIsCadImport())) {
                    MultiFactoryControlVO multiFactoryControlVO = (MultiFactoryControlVO)controlVOS.get(0);
                    if (!Boolean.TRUE.equals(multiFactoryControlVO.getShowBomPurpose())) {
                        variation1 = null;
                    }

                    if (!Boolean.TRUE.equals(multiFactoryControlVO.getShowSpareBom())) {
                        variation2 = null;
                    }
                }

                Map<BigInteger, PartDO> partDOMap = this.queryPartByMasterOids(masterDOMap, userDO, viewDefDO.getOid(), newPartViewNumberOidMap, variation1, variation2);
                allUpdatePartDOMap.putAll(partDOMap);
                allNewPartViewNumberOidMap.putAll(newPartViewNumberOidMap);
            }
        }

        basicListDTO.setAllViewDefDOMap(allViewDefDOMap);
        basicListDTO.setAllNewMasterNumberList(allNewMasterNumerList);
        basicListDTO.setAllNewPartViewNumberOidMap(allNewPartViewNumberOidMap);
        basicListDTO.setAllUpdatePartDOMap(allUpdatePartDOMap);
        basicListDTO.setAllMasterDOMap(allMasterDOMap);
        basicListDTO.setPartNumberMap(partNumberMap);
        basicListDTO.setIdNumberMap(idNumberMap);
        return basicListDTO;
    }

    private Map<String, PartMasterDO> getViewMasterDo(Map<String, PartMasterDO> allMasterDOMap, List<String> partNumbers) {
        Map<String, PartMasterDO> viewMasterDOMap = new HashMap();
        Iterator var4 = partNumbers.iterator();

        while(var4.hasNext()) {
            String partNumber = (String)var4.next();
            if (Objects.nonNull(allMasterDOMap.get(partNumber))) {
                viewMasterDOMap.put(partNumber, allMasterDOMap.get(partNumber));
            }
        }

        return viewMasterDOMap;
    }

    private Collection<String> batchQueryMasterDOByNumbers(List<String> allMasterNumbers, Map<String, PartMasterDO> allMasterDOMap) {
        Collection<String> allNewMasterNumerList = new ArrayList();
        Map<String, PartMasterDO> masterDOMap = this.queryPartMasterByNumbers(allMasterNumbers);
        if (!CollectionUtils.isEmpty(masterDOMap)) {
            allMasterDOMap.putAll(masterDOMap);
            String[] masteridArray = new String[masterDOMap.keySet().size()];
            List<String> dbNumerList = Arrays.asList(masterDOMap.keySet().toArray(masteridArray));
            Collection<String> newMasterNumerList = org.apache.commons.collections4.CollectionUtils.subtract(allMasterNumbers, dbNumerList);
            allNewMasterNumerList.addAll(newMasterNumerList);
        } else {
            allNewMasterNumerList.addAll(allMasterNumbers);
        }

        return allNewMasterNumerList;
    }

    public Map<String, PartMasterDO> queryPartMasterByNumbers(List<String> numberList) {
        Map<String, PartMasterDO> partMasterDOMap = new HashMap();
        if (!CollectionUtils.isEmpty(numberList)) {
            List<List<String>> pieceList = CommonUtil.subObjectList(CollUtil.distinct(numberList), this.queryPartNumbercount);
            List<PartMasterDO> partMasterDOS = new ArrayList();
            Iterator var5 = pieceList.iterator();

            while(var5.hasNext()) {
                List<String> numbers = (List)var5.next();
                List<PartMasterDO> masterDOS = this.typlmPartService.queryPartMasterList(numbers);
                if (CollUtil.isNotEmpty(masterDOS)) {
                    partMasterDOS.addAll(masterDOS);
                }
            }

            if (!CollectionUtils.isEmpty(partMasterDOS)) {
                partMasterDOS.forEach((item) -> {
                    PartMasterDO var10000 = (PartMasterDO)partMasterDOMap.put(item.getPartnumber(), item);
                });
            }
        }

        return partMasterDOMap;
    }

    private void checkNameEmpty(PartXmlAllNodeDTO partXmlAllNodeDTO, List<Map<ResponseCodeEnum, String[]>> exceptions) {
        List<PartXmlNodeDTO> partList = partXmlAllNodeDTO.getPartList();
        if (CollUtil.isNotEmpty(partList)) {
            Iterator var4 = partList.iterator();

            while(var4.hasNext()) {
                PartXmlNodeDTO partXmlNodeDTO = (PartXmlNodeDTO)var4.next();
                if (StringUtils.isBlank(partXmlNodeDTO.getPartname())) {
                    TyplmExceptionUtil.addExceptions(ResponseCodeEnum.BIZ_OBJECT_PARAM_CANNOT_EMPTY, new String[]{partXmlNodeDTO.getPartnumber(), "名称"}, exceptions);
                }
            }
        }

        if (CollUtil.isNotEmpty(exceptions)) {
            TyException.throwMultiTyException(exceptions);
        }

    }

    private void checkNewPartStrategy(Collection<String> allNewMasterNumberList, boolean isCreatePart, List<Map<ResponseCodeEnum, String[]>> exceptions) {
        if (!CollectionUtils.isEmpty(allNewMasterNumberList) && !isCreatePart) {
            TyplmExceptionUtil.addExceptions(ResponseCodeEnum.BIZ_PART_NOT_FOUND, allNewMasterNumberList.toString(), exceptions);
            if (!CollectionUtils.isEmpty(exceptions)) {
                TyException.throwMultiTyException(exceptions);
            }
        }

    }

    private void checkNewPartVersionStrategy(Map<String, BigInteger> allNewPartViewNumberOidMap, boolean isCreatePart, String viewName, List<Map<ResponseCodeEnum, String[]>> exceptions) {
        if (!CollectionUtils.isEmpty(allNewPartViewNumberOidMap)) {
            List<String> allNewVersionNumberList = new ArrayList(allNewPartViewNumberOidMap.keySet());
            if (!CollectionUtils.isEmpty(allNewVersionNumberList) && !isCreatePart) {
                TyplmExceptionUtil.addExceptions(ResponseCodeEnum.BIZ_PART_VIEW_NOT_EXISTS, new String[]{allNewVersionNumberList.toString(), viewName}, exceptions);
                if (!CollectionUtils.isEmpty(exceptions)) {
                    TyException.throwMultiTyException(exceptions);
                }
            }
        }

    }

    private void collectAllQueryData(PartXmlAllNodeDTO xmlDTO, TyPartImportBasicListDTO importBasicListDTO, List<Map<ResponseCodeEnum, String[]>> exceptions) {
        PartXmlGlobeNodeDTO globeNodeDTO = xmlDTO.getGlobe();
        List<BigInteger> subfolderOidList = new ArrayList();
        List<TyFolderPathDTO> allQuerySubfolderPathList = new ArrayList();
        List<String> typeList = new ArrayList();
        List<String> attrKeyList = new ArrayList();
        Map<String, List<String>> allContainerNameMap = new HashMap();
        Map<String, List<BigInteger>> allContainerIdMap = new HashMap();
        Map<String, PartTypeRelDTO> partTypeRelDTOList = new HashMap();
        List<String> allNewPart = this.typlmPartBomImportCheckUtil.getAllNewPart(importBasicListDTO);
        Map<String, PartXmlNodeDTO> partNumberMap = importBasicListDTO.getPartNumberMap();
        Map<String, String> containerMap = new HashMap();
        Iterator var15 = allNewPart.iterator();

        while(var15.hasNext()) {
            String partNumber = (String)var15.next();
            PartXmlNodeDTO partXmlNodeDTO = (PartXmlNodeDTO)partNumberMap.get(partNumber);
            boolean isAllowRootNode = "true".equalsIgnoreCase(importBasicListDTO.getIsCadImport()) || "saveAs".equalsIgnoreCase(importBasicListDTO.getIsCadImport());
            this.addTypeToList(partXmlNodeDTO, globeNodeDTO, typeList, isAllowRootNode);
            this.addContainerToMap(partXmlNodeDTO, globeNodeDTO, allContainerNameMap, allContainerIdMap, exceptions);
            this.addFolderPathToList(partXmlNodeDTO, globeNodeDTO, subfolderOidList, allQuerySubfolderPathList, containerMap);
            this.addPartVersionToList(partXmlNodeDTO, globeNodeDTO, partTypeRelDTOList);
            this.addIbaKeyToList(partXmlNodeDTO.getAttributes(), attrKeyList);
        }

        Map<BigInteger, PartDO> allUpdatePartDOMap = importBasicListDTO.getAllUpdatePartDOMap();
        if (!CollectionUtils.isEmpty(allUpdatePartDOMap)) {
            Iterator var23 = allUpdatePartDOMap.entrySet().iterator();

            label53:
            while(true) {
                PartMasterDO masterDo;
                do {
                    if (!var23.hasNext()) {
                        break label53;
                    }

                    Map.Entry<BigInteger, PartDO> entry = (Map.Entry)var23.next();
                    masterDo = this.typlmPartBomImportCheckUtil.getMasterDo(importBasicListDTO, (BigInteger)entry.getKey());
                } while(!Objects.nonNull(masterDo));

                PartXmlNodeDTO partXmlNodeDTO = (PartXmlNodeDTO)partNumberMap.get(masterDo.getPartnumber());
                boolean isAllowRootNode = "true".equalsIgnoreCase(importBasicListDTO.getIsCadImport()) || "saveAs".equalsIgnoreCase(importBasicListDTO.getIsCadImport());
                this.addTypeToList(partXmlNodeDTO, globeNodeDTO, typeList, isAllowRootNode);
                this.addIbaKeyToList(partXmlNodeDTO.getAttributes(), attrKeyList);
            }
        }

        List<PartXmlStructNodeDTO> partStruct = xmlDTO.getPartStruct();
        partStruct.forEach((struct) -> {
            this.addIbaKeyToList(struct.getAttributes(), attrKeyList);
        });
        List<String> attrKeys = new ArrayList();
        Set<String> attrKeySet = new HashSet();
        Iterator var29 = attrKeyList.iterator();

        while(true) {
            while(var29.hasNext()) {
                String attrKey = (String)var29.next();
                String[] split = attrKey.split("&&");
                if (split.length == 2 && attrKeySet.add(split[1])) {
                    attrKeys.add(split[1]);
                } else if (split.length != 2) {
                    attrKeys.add(attrKey);
                }
            }

            importBasicListDTO.setAllTypeQueryList(typeList);
            importBasicListDTO.setAllAttrKeyQueryList(attrKeys);
            importBasicListDTO.setAllSubfolderOidQueryList(subfolderOidList);
            importBasicListDTO.setAllSubfolderPathQueryList(allQuerySubfolderPathList);
            importBasicListDTO.setAllContainerNameQueryMap(allContainerNameMap);
            importBasicListDTO.setAllContainerIdQueryMap(allContainerIdMap);
            importBasicListDTO.setNumberTypeRelDTOMap(partTypeRelDTOList);
            importBasicListDTO.setContainerQueryCabinetMap(containerMap);
            return;
        }
    }

    private void addPartVersionToList(PartXmlNodeDTO partXmlNodeDTO, PartXmlGlobeNodeDTO globeNodeDTO, Map<String, PartTypeRelDTO> versionDTOList) {
        PartTypeRelDTO partTypeRelDTO = new PartTypeRelDTO();
        if (StringUtils.isEmpty(partXmlNodeDTO.getVersion())) {
            partXmlNodeDTO.setVersion(globeNodeDTO.getVersion());
            partTypeRelDTO.setUserSetVersion(globeNodeDTO.getVersion());
            partTypeRelDTO.setSeriesOutVersion(globeNodeDTO.getVersion());
        }

        if (StringUtils.isEmpty(partXmlNodeDTO.getLifecyclestate())) {
            partXmlNodeDTO.setLifecyclestate(globeNodeDTO.getLifecyclestate());
            partTypeRelDTO.setLifecyclestateOid(globeNodeDTO.getLifecyclestateOid());
        }

        partTypeRelDTO.setPartNumber(partXmlNodeDTO.getPartnumber());
        partTypeRelDTO.setParttype(partXmlNodeDTO.getParttypedefname());
        partTypeRelDTO.setParttypeDisplay(partXmlNodeDTO.getParttype());
        partTypeRelDTO.setUserSetVersion(partXmlNodeDTO.getVersion());
        partTypeRelDTO.setLifecyclestate(partXmlNodeDTO.getLifecyclestate());
        partTypeRelDTO.setContainterName(partXmlNodeDTO.getContainername());
        if (StringUtils.isNotEmpty(partXmlNodeDTO.getContaineroid())) {
            partTypeRelDTO.setContainterOID(new BigInteger(partXmlNodeDTO.getContaineroid()));
        }

        partTypeRelDTO.setContainterOType(partXmlNodeDTO.getContainerotype());
        versionDTOList.put(partXmlNodeDTO.getPartnumber(), partTypeRelDTO);
    }

    private void addFolderPathToList(PartXmlNodeDTO partXmlNodeDTO, PartXmlGlobeNodeDTO globeNodeDTO, List<BigInteger> folderOidList, List<TyFolderPathDTO> folderPathList, Map<String, String> containerMap) {
        if (StringUtils.isEmpty(partXmlNodeDTO.getSubfolderid()) && StringUtils.isEmpty(partXmlNodeDTO.getSubfolderpath())) {
            partXmlNodeDTO.setSubfolderid(globeNodeDTO.getSubfolderid());
            partXmlNodeDTO.setSubfolderpath(globeNodeDTO.getSubfolderpath());
        }

        if (!StringUtils.isEmpty(partXmlNodeDTO.getSubfolderid())) {
            folderOidList.add(new BigInteger(partXmlNodeDTO.getSubfolderid()));
        } else if (!StringUtils.isEmpty(partXmlNodeDTO.getSubfolderpath()) && !"/".equalsIgnoreCase(partXmlNodeDTO.getSubfolderpath())) {
            String contextTypeByContainerOtype = EntityBaseUtil.getContextTypeByContainerOtype(partXmlNodeDTO.getContainerotype());
            boolean anyMatch = folderPathList.stream().anyMatch((path) -> {
                return path.getContainerName().equalsIgnoreCase(partXmlNodeDTO.getContainername()) && path.getContainerType().equalsIgnoreCase(contextTypeByContainerOtype) && path.getFolderPath().equalsIgnoreCase(partXmlNodeDTO.getSubfolderpath());
            });
            if (!anyMatch) {
                TyFolderPathDTO tyFolderPathDTO = new TyFolderPathDTO();
                tyFolderPathDTO.setContainerName(partXmlNodeDTO.getContainername());
                tyFolderPathDTO.setContainerType(contextTypeByContainerOtype);
                tyFolderPathDTO.setFolderPath(partXmlNodeDTO.getSubfolderpath());
                folderPathList.add(tyFolderPathDTO);
            }
        } else {
            containerMap.put(partXmlNodeDTO.getContaineroid(), partXmlNodeDTO.getOptype());
        }

    }

    private void addContainerToMap(PartXmlNodeDTO partXmlNodeDTO, PartXmlGlobeNodeDTO globeNodeDTO, Map<String, List<String>> allContainerNameMap, Map<String, List<BigInteger>> allContainerIdMap, List<Map<ResponseCodeEnum, String[]>> exceptions) {
        String containerType = partXmlNodeDTO.getContainerotype();
        String containerName = partXmlNodeDTO.getContainername();
        String strContainerOid = partXmlNodeDTO.getContaineroid();
        if (StringUtils.isNotBlank(strContainerOid) && StringUtils.isNotBlank(containerType)) {
            partXmlNodeDTO.setContainerotype(containerType);
            partXmlNodeDTO.setContaineroid(strContainerOid);
        } else if (StringUtils.isEmpty(containerType) || StringUtils.isEmpty(containerName)) {
            containerType = globeNodeDTO.getContainerotype();
            partXmlNodeDTO.setContainerotype(containerType);
            partXmlNodeDTO.setContaineroid(globeNodeDTO.getContaineroid());
            partXmlNodeDTO.setContainername(globeNodeDTO.getContainername());
        }

        if (ContainerConstant.getNormalContainerOtype().contains(containerType)) {
            if (StringUtils.isNotEmpty(partXmlNodeDTO.getContaineroid())) {
                BigInteger containerOid = new BigInteger(partXmlNodeDTO.getContaineroid());
                this.typlmPartBomImportUtil.addContainerOidToMap(allContainerIdMap, containerType, containerOid);
            } else {
                this.addContainerNameToMap(allContainerNameMap, containerType, partXmlNodeDTO.getContainername());
            }
        } else {
            TyplmExceptionUtil.addExceptions(ResponseCodeEnum.BIZ_CONTAINER_TYPE_ERROR, containerType, exceptions);
        }

    }

    private void addContainerNameToMap(Map<String, List<String>> allContainerNameMap, String containerotype, String containerName) {
        List<String> listContainerNames = (List)allContainerNameMap.get(containerotype);
        if (CollectionUtils.isEmpty((Collection)listContainerNames)) {
            listContainerNames = new ArrayList();
        }

        this.typlmPartBomImportCheckUtil.addStringToList(containerName, (List)listContainerNames);
        allContainerNameMap.put(containerotype, listContainerNames);
    }

    private void addTypeToList(PartXmlNodeDTO partXmlNodeDTO, PartXmlGlobeNodeDTO partXmlGlobeNodeDTO, List<String> typeList, boolean isAllowRootNode) {
        if (!isAllowRootNode && "ty.inteplm.part.CTyPart".equalsIgnoreCase(partXmlNodeDTO.getParttypedefname())) {
            log.debug("当前类型：" + partXmlNodeDTO.getParttypedefname() + ":" + isAllowRootNode);
        }

        if (StringUtils.isNotEmpty(partXmlNodeDTO.getParttypedefname())) {
            this.typlmPartBomImportCheckUtil.addStringToList(partXmlNodeDTO.getParttypedefname(), typeList);
        } else {
            partXmlNodeDTO.setParttype(partXmlGlobeNodeDTO.getParttype());
            partXmlNodeDTO.setParttypedefname(partXmlGlobeNodeDTO.getParttypedefname());
            this.typlmPartBomImportCheckUtil.addStringToList(partXmlNodeDTO.getParttypedefname(), typeList);
        }

    }

    private void addIbaKeyToList(List<ImportAttributeDTO> attributes, List<String> attrKeyList) {
        if (!CollectionUtils.isEmpty(attributes)) {
            attributes.forEach((item) -> {
                this.typlmPartBomImportCheckUtil.addStringToList(item.getAttributeKey(), attrKeyList);
            });
        }

    }

    private Map<String, List<PartImportLogVO>> importPartAndBom(UserDO userDO, PartXmlAllNodeDTO partXmlAllNodeDTO, String isCadImport, Map<String, MDAImportOutDocVo> docXmlIdMap) {
        TimeInterval timeInterval = new TimeInterval();
        PartXmlGlobeNodeDTO globeDTO = partXmlAllNodeDTO.getGlobe();
        globeDTO.setIsCadImport(isCadImport);
        this.typlmExecutePartImportExtensionUtil.handleBeforeCreatePartBom(userDO, partXmlAllNodeDTO);
        Map<String, List<PartImportLogVO>> returnLogMap = this.initLogMap();
        List<Map<ResponseCodeEnum, String[]>> exceptions = new ArrayList();
        this.checkNameEmpty(partXmlAllNodeDTO, exceptions);
        this.typlmExecutePartImportExtensionUtil.handleBeforeCreatePartBomLog(returnLogMap);
        timeInterval.restart();
        TyPartImportBasicListDTO importBasicListDTO = this.queryAllPartByNumbers(partXmlAllNodeDTO.getPartList(), partXmlAllNodeDTO.getGlobe(), userDO, exceptions);
        TyplmLoggerUtil.debug(log, () -> {
            return "batchImportPartBom ==> 根据零件编码及视图批量获取零件信息 耗时=【{}】 ms";
        }, () -> {
            return new Object[]{timeInterval.interval()};
        });
        timeInterval.restart();
        importBasicListDTO.setIsCadImport(isCadImport);
        if ("true".equalsIgnoreCase(isCadImport)) {
            importBasicListDTO.setCadXmlIdMap(docXmlIdMap);
            importBasicListDTO.setDocPartStruct(partXmlAllNodeDTO.getDocPartStruct());
            importBasicListDTO.setPartLinkType(globeDTO.getPartLinkType());
            if (Boolean.TRUE.equals(this.copyDerivedImage)) {
                globeDTO.setCopyDerivedimage(isCadImport);
            }

            if (!CollectionUtils.isEmpty(partXmlAllNodeDTO.getPartList()) && ObjectUtils.isNotEmpty(partXmlAllNodeDTO.getPartList().get(0)) && "dwgpart".equalsIgnoreCase(((PartXmlNodeDTO)partXmlAllNodeDTO.getPartList().get(0)).getOptype())) {
                globeDTO.setCopyPartStruct("true");
            }
        }

        TyplmLoggerUtil.debug(log, () -> {
            return "batchImportPartBom ==> 解析关联策略 耗时=【{}】 ms";
        }, () -> {
            return new Object[]{timeInterval.interval()};
        });
        timeInterval.restart();
        this.checkNewPartStrategy(importBasicListDTO.getAllNewMasterNumberList(), importBasicListDTO.isCreatePart(), exceptions);
        TyplmLoggerUtil.debug(log, () -> {
            return "batchImportPartBom ==> 若选择的策略为不创建零件 耗时=【{}】 ms";
        }, () -> {
            return new Object[]{timeInterval.interval()};
        });
        timeInterval.restart();
        this.checkNewPartVersionStrategy(importBasicListDTO.getAllNewPartViewNumberOidMap(), importBasicListDTO.isCreatePart(), globeDTO.getView(), exceptions);
        TyplmLoggerUtil.debug(log, () -> {
            return "batchImportPartBom ==> 新建视图版本的零件 耗时=【{}】 ms";
        }, () -> {
            return new Object[]{timeInterval.interval()};
        });
        timeInterval.restart();
        this.collectAllQueryData(partXmlAllNodeDTO, importBasicListDTO, exceptions);
        TyplmLoggerUtil.debug(log, () -> {
            return "batchImportPartBom ==> 收集所有要导入的数据 耗时=【{}】 ms";
        }, () -> {
            return new Object[]{timeInterval.interval()};
        });
        timeInterval.restart();
        this.batchQueryAndCheckData(userDO, importBasicListDTO, partXmlAllNodeDTO, returnLogMap, exceptions);
        TyplmLoggerUtil.debug(log, () -> {
            return "batchImportPartBom ==> 批量查询零件类型 耗时=【{}】 ms";
        }, () -> {
            return new Object[]{timeInterval.interval()};
        });
        timeInterval.restart();
        PartImportToDBDTO partImportToDBDTO = this.buildPartAndBom(userDO, partXmlAllNodeDTO, returnLogMap, importBasicListDTO);
        TyplmLoggerUtil.debug(log, () -> {
            return "batchImportPartBom ==> 构造批量插入的零件信息及BOM信息 耗时=【{}】 ms";
        }, () -> {
            return new Object[]{timeInterval.interval()};
        });
        timeInterval.restart();
        this.checkPartDocBuildLink(importBasicListDTO, partImportToDBDTO.getCadBuildRuleDTOList(), exceptions);
        TyplmLoggerUtil.debug(log, () -> {
            return "batchImportPartBom ==> 对于需要创建构造关系的数据进行数据校验 耗时=【{}】 ms";
        }, () -> {
            return new Object[]{timeInterval.interval()};
        });
        timeInterval.restart();
        this.batchImportDataToDB(userDO, globeDTO, partImportToDBDTO, partXmlAllNodeDTO, docXmlIdMap, importBasicListDTO, exceptions, isCadImport);
        List<PartImportLogVO> partImportLogVOS = (List)returnLogMap.get("normalLog");
        if (CollUtil.isNotEmpty(partImportLogVOS)) {
            List<PartImportLogVO> checkInList = (List)partImportLogVOS.stream().filter((partImportLogVO) -> {
                return "check_in".equalsIgnoreCase(partImportLogVO.getEvent());
            }).collect(Collectors.toList());
            if (CollUtil.isNotEmpty(checkInList)) {
                checkInList.forEach((partImportLogVO) -> {
                    this.typlmLogger.info(new CTyEntityBaseDO(EntityBaseUtil.getOidByStr(partImportLogVO.getPartOid(), BigInteger.ZERO), "ty.inteplm.part.CTyPart"), LogEventEnum.CHECK_IN);
                });
            }
        }

        TyplmLoggerUtil.debug(log, () -> {
            return "batchImportPartBom ==> 批量保存零件及BOM数据到数据库 耗时=【{}】 ms";
        }, () -> {
            return new Object[]{timeInterval.interval()};
        });
        timeInterval.restart();
        this.typlmExecutePartImportExtensionUtil.processAfterImport(partXmlAllNodeDTO, docXmlIdMap, importBasicListDTO);
        TyplmLoggerUtil.debug(log, () -> {
            return "batchImportPartBom ==> 执行批量录入后处理逻辑 耗时=【{}】 ms";
        }, () -> {
            return new Object[]{timeInterval.interval()};
        });
        return returnLogMap;
    }

    private void buildNumMap(TyPartImportBasicListDTO importBasicListDTO, Map<BigInteger, String> linkOidAndNumMap, Map<BigInteger, String> masteroidAndNumMap, Map<BigInteger, String> oidAndNumMap, Map<BigInteger, String> linkOidAndNumCADMap) {
        if (!ObjectUtils.isEmpty(importBasicListDTO)) {
            Map<String, PartDO> allAfterUpgradePartDOMap = importBasicListDTO.getAllAfterUpgradePartDOMap();
            Map<String, PartMasterDO> allMasterDOMap = importBasicListDTO.getAllMasterDOMap();
            Map<String, PartDO> allNewMasterNumberPartMap = importBasicListDTO.getAllNewMasterNumberPartMap();
            Iterator var9;
            Map.Entry entry;
            String key;
            PartDO value1;
            if (ObjectUtils.isNotEmpty(allAfterUpgradePartDOMap)) {
                var9 = allAfterUpgradePartDOMap.entrySet().iterator();

                while(var9.hasNext()) {
                    entry = (Map.Entry)var9.next();
                    key = (String)entry.getKey();
                    value1 = (PartDO)entry.getValue();
                    if (ObjectUtils.isNotEmpty(value1)) {
                        linkOidAndNumMap.put(value1.getOid(), key);
                        masteroidAndNumMap.put(value1.getMasteredoid(), key);
                    }
                }
            }

            if (ObjectUtils.isNotEmpty(allMasterDOMap)) {
                var9 = allMasterDOMap.entrySet().iterator();

                while(var9.hasNext()) {
                    entry = (Map.Entry)var9.next();
                    key = (String)entry.getKey();
                    PartMasterDO value = (PartMasterDO)entry.getValue();
                    if (ObjectUtils.isNotEmpty(value)) {
                        oidAndNumMap.put(value.getOid(), key);
                    }
                }
            }

            if (ObjectUtils.isNotEmpty(allNewMasterNumberPartMap)) {
                var9 = allNewMasterNumberPartMap.entrySet().iterator();

                while(var9.hasNext()) {
                    entry = (Map.Entry)var9.next();
                    key = (String)entry.getKey();
                    PartDO value = (PartDO)entry.getValue();
                    if (ObjectUtils.isNotEmpty(value)) {
                        linkOidAndNumCADMap.put(value.getOid(), key);
                    }
                }
            }

        }
    }

    private void copyPartDescribeLink(PartImportToDBDTO partImportToDBDTO) {
        Map<PartDO, PartDO> sourceAndTargetPartMap = MapUtils.isNotEmpty(partImportToDBDTO.getSourceAndTargetPartRel()) ? partImportToDBDTO.getSourceAndTargetPartRel() : partImportToDBDTO.getSourceAndTargetPartRelCopyUsageLink();
        if (MapUtils.isNotEmpty(sourceAndTargetPartMap)) {
            List<BigInteger> sourceOidSet = new ArrayList();
            Map<BigInteger, BigInteger> sourceTargetMap = new HashMap();
            sourceAndTargetPartMap.forEach((sourcePart, targetPart) -> {
                sourceOidSet.add(sourcePart.getOid());
                sourceTargetMap.put(sourcePart.getOid(), targetPart.getOid());
            });
            List<PartDescribeLinkDO> partDescribeLinkDOS = BatchQueryHelper.batchSplitQuery(CollUtil.distinct(sourceOidSet), (item) -> {
                return this.typlmPartDescribeLinkBugFixMapper.batchQueryNewestPartDescribelinkByPartOids(new ArrayList(item));
            });
            Iterator<PartDescribeLinkDO> iterator = partDescribeLinkDOS.iterator();

            while(iterator.hasNext()) {
                PartDescribeLinkDO partDescribeLinkDO = (PartDescribeLinkDO)iterator.next();
                BigInteger targetOid = (BigInteger)sourceTargetMap.get(partDescribeLinkDO.getAoid());
                if (Objects.isNull(targetOid)) {
                    iterator.remove();
                } else {
                    partDescribeLinkDO.setOid(this.snowflakeIdComponent.getInstance().nextId());
                    partDescribeLinkDO.setAoid(targetOid);
                    TyplmEntityBaseUtil.fillCommonFieldForCreate(partDescribeLinkDO);
                }
            }

            if (CollUtil.isNotEmpty(partDescribeLinkDOS)) {
                this.typlmEntityBaseService.batchInsertWithCommit(partDescribeLinkDOS);
            }
        }

    }

    private Map<String, String> buildPartNumAndFileNameMap(PartImportToDBDTO partImportToDBDTO, PartXmlAllNodeDTO partXmlAllNodeDTO, Map<String, MDAImportOutDocVo> docXmlIdMap, Map<String, String> partAndName) {
        if (ObjectUtil.isEmpty(docXmlIdMap)) {
            return Collections.emptyMap();
        } else {
            Map<String, String> partNumberIdMap = (Map)((List)Optional.ofNullable(partXmlAllNodeDTO.getPartList()).orElse(Collections.emptyList())).stream().collect(Collectors.toMap(PartXmlNodeDTO::getPartnumber, PartXmlNodeDTO::getId, (k1, k2) -> {
                return k1;
            }));
            Map<String, List<String>> partIdCadIdMap = (Map)((List<ImportStructDTO>)Optional.ofNullable(partXmlAllNodeDTO.getDocPartStruct()).orElse(Collections.emptyList())).stream().filter((t) -> {
                return StringUtils.isNotBlank(t.getParentId()) && StringUtils.isNotBlank(t.getChildId());
            }).collect(Collectors.groupingBy(ImportStructDTO::getParentId, Collectors.mapping(ImportStructDTO::getChildId, Collectors.toList())));
            Map<String, String> cadIdFileNameMap = (Map)docXmlIdMap.entrySet().stream().filter((t) -> {
                return t.getValue() != null && StringUtils.isNotBlank(((MDAImportOutDocVo)t.getValue()).getFileName());
            }).collect(Collectors.toMap(Map.Entry::getKey, (t) -> {
                return ((MDAImportOutDocVo)t.getValue()).getFileName();
            }));
            int size = (partImportToDBDTO.getPartDOInsertList().size() + partImportToDBDTO.getPartDOUpdateList().size()) * 2;
            Map<BigInteger, String> partMasterOidNumberMap = new HashMap(size);
            partImportToDBDTO.getPartMasterDOInsertList().forEach((t) -> {
                String var10000 = (String)partMasterOidNumberMap.put(t.getOid(), t.getPartnumber());
            });
            partImportToDBDTO.getPartMasterNameUpdateList().forEach((t) -> {
                String var10000 = (String)partMasterOidNumberMap.put(t.getOid(), t.getPartnumber());
            });
            Map<BigInteger, String> oidPartNumberMap = new HashMap(size);
            partImportToDBDTO.getPartDOInsertList().forEach((t) -> {
                String partNumber = t.getPartnumber();
                if (StringUtils.isEmpty(partNumber)) {
                    partNumber = (String)partMasterOidNumberMap.getOrDefault(t.getMasteredoid(), "");
                }

                oidPartNumberMap.put(t.getOid(), partNumber);
                oidPartNumberMap.put(t.getMasteredoid(), partNumber);
            });
            partImportToDBDTO.getPartDOUpdateList().forEach((t) -> {
                String partNumber = t.getPartnumber();
                if (StringUtils.isEmpty(partNumber)) {
                    partNumber = (String)partMasterOidNumberMap.getOrDefault(t.getMasteredoid(), "");
                }

                oidPartNumberMap.put(t.getOid(), partNumber);
                oidPartNumberMap.put(t.getMasteredoid(), partNumber);
            });
            Map<String, String> oidFileNameMap = new HashMap(oidPartNumberMap.size());
            Iterator var12 = oidPartNumberMap.entrySet().iterator();

            while(var12.hasNext()) {
                Map.Entry<BigInteger, String> entry = (Map.Entry)var12.next();
                String partNumber = (String)entry.getValue();
                if (!StringUtils.isBlank(partNumber)) {
                    String partXmlId = (String)partNumberIdMap.getOrDefault(partNumber, "");
                    if (StringUtils.isNotBlank(partXmlId) && ObjectUtil.isNotEmpty(partAndName)) {
                        List<String> cadIdList = (List)partIdCadIdMap.getOrDefault(partXmlId, Collections.emptyList());
                        if (ObjectUtil.isNotEmpty(cadIdList)) {
                            List<String> fileNameList = (List)cadIdList.stream().map((t) -> {
                                return (String)cadIdFileNameMap.getOrDefault(t, "");
                            }).filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList());
                            oidFileNameMap.put(partNumber + "," + (String)partAndName.get(partNumber), String.join(",", fileNameList));
                        }
                    }
                }
            }

            return oidFileNameMap;
        }
    }

    private void throwException(List<Map<ResponseCodeEnum, String[]>> exceptions, String isCadImport, PartImportToDBDTO partImportToDBDTO, PartXmlAllNodeDTO partXmlAllNodeDTO, Map<String, MDAImportOutDocVo> docXmlIdMap, Map<String, String> partAndName) {
        if (!CollUtil.isEmpty(exceptions)) {
            Set<String> partNumberSet = new HashSet();
            List<Map<ResponseCodeEnum, String[]>> exceptionsDistinct = new ArrayList();
            Iterator var9 = exceptions.iterator();

            while(true) {
                while(true) {
                    Map exception;
                    do {
                        if (!var9.hasNext()) {
                            Map<String, String> partNumberAndNameMap = new HashMap();
                            if ("true".equalsIgnoreCase(isCadImport)) {
                                partNumberAndNameMap = this.buildPartNumAndFileNameMap(partImportToDBDTO, partXmlAllNodeDTO, docXmlIdMap, partAndName);
                            }

                            Map<String, StringBuilder> messageMap = new HashMap();
                            Iterator var23 = exceptionsDistinct.iterator();

                            String key1;
                            while(var23.hasNext()) {
                                Map<ResponseCodeEnum, String[]> emap = (Map)var23.next();
                                if (ObjectUtils.isNotEmpty(emap)) {
                                    Map.Entry<ResponseCodeEnum, String[]> map = (Map.Entry)emap.entrySet().iterator().next();
                                    String[] params = (String[])map.getValue();
                                    TyException tye;
                                    if (StringUtils.isAllEmpty(params)) {
                                        tye = new TyException((ResponseCodeEnum)map.getKey());
                                    } else {
                                        tye = new TyException((ResponseCodeEnum)map.getKey(), params);
                                    }

                                    if (!ObjectUtils.isEmpty(tye) && !ObjectUtils.isEmpty(tye.getObjects()) && !ObjectUtils.isEmpty(tye.getResponseCodeEnum())) {
                                        String localeMessage = tye.getResponseCodeEnum().getLocaleMessage(tye.getObjects());
                                        if (!StringUtils.isBlank(localeMessage)) {
                                            boolean flag = localeMessage.contains("]中的");
                                            if (flag) {
                                                key1 = null;
                                                String key2 = null;
                                                Optional<Object> firstOptional = Arrays.stream(tye.getObjects()).findFirst();
                                                if (firstOptional.isPresent() && ObjectUtils.isNotEmpty(firstOptional.get())) {
                                                    key1 = firstOptional.get().toString();
                                                    key2 = "[" + key1 + "]中的";
                                                }

                                                if (!StringUtils.isBlank(key1)) {
                                                    localeMessage = localeMessage.replace(key2, "");
                                                    if (messageMap.containsKey(key1)) {
                                                        ((StringBuilder)messageMap.get(key1)).append(";").append(localeMessage);
                                                    } else {
                                                        messageMap.put(key1, new StringBuilder(localeMessage));
                                                    }
                                                }
                                            } else {
                                                messageMap.put(localeMessage, new StringBuilder());
                                            }
                                        }
                                    }
                                }
                            }

                            int size = messageMap.size();
                            int messageMapCount = 0;
                            List<Map<ResponseCodeEnum, String[]>> exceptionFirst = new ArrayList();
                            List<Map<ResponseCodeEnum, String[]>> exceptionSecond = new ArrayList();
                            Iterator var30 = messageMap.entrySet().iterator();

                            while(var30.hasNext()) {
                                Map.Entry<String, StringBuilder> entry = (Map.Entry)var30.next();
                                StringBuilder value = (StringBuilder)entry.getValue();
                                ++messageMapCount;
                                EnumMap moodMap;
                                if (ObjectUtils.isEmpty(value)) {
                                    key1 = (String)entry.getKey();
                                    moodMap = new EnumMap(ResponseCodeEnum.class);
                                    moodMap.put(ResponseCodeEnum.BATCH_SAVE_IBA_EXCEPTION, new String[]{key1});
                                    exceptionFirst.add(moodMap);
                                } else {
                                    key1 = ObjectUtil.isNotEmpty(partNumberAndNameMap) ? "图纸[" + (String)((Map)partNumberAndNameMap).get(entry.getKey()) + "]中的" + ((StringBuilder)entry.getValue()).toString() : "零部件[" + (String)entry.getKey() + "]中的" + ((StringBuilder)entry.getValue()).toString();
                                    if (ObjectUtil.isNotEmpty(partNumberAndNameMap) && messageMapCount < size) {
                                        key1 = key1 + ";\n";
                                    }

                                    moodMap = new EnumMap(ResponseCodeEnum.class);
                                    moodMap.put(ResponseCodeEnum.BATCH_SAVE_IBA_EXCEPTION, new String[]{key1});
                                    exceptionSecond.add(moodMap);
                                }
                            }

                            exceptionFirst.addAll(exceptionSecond);
                            if (CollUtil.isNotEmpty(exceptionFirst)) {
                                TyException.throwMultiTyException(exceptionFirst);
                            }

                            return;
                        }

                        exception = (Map)var9.next();
                    } while(!ObjectUtils.isNotEmpty(exception));

                    Map.Entry<ResponseCodeEnum, String[]> map = (Map.Entry)exception.entrySet().iterator().next();
                    String[] params = (String[])map.getValue();
                    if (params != null && params.length > 1) {
                        String partNumberAndName = params[0] + "&" + params[1];
                        if (StringUtils.isNotBlank(partNumberAndName) && partNumberSet.add(partNumberAndName)) {
                            exceptionsDistinct.add(exception);
                        }
                    } else {
                        exceptionsDistinct.add(exception);
                    }
                }
            }
        }
    }

    private void copyAttrs(List<PartDO> sourceParts, List<PartDO> targetParts, TyplmCopyAttrParamDTO paramDTO) {
        if (!org.apache.commons.collections4.CollectionUtils.isEmpty(sourceParts) && !org.apache.commons.collections4.CollectionUtils.isEmpty(targetParts)) {
            List<ObjLinkCopyDTO> partLinkCopyList = new ArrayList();
            List<CopyDTO> copyDTOS = new ArrayList();

            for(int i = 0; i < targetParts.size(); ++i) {
                ObjLinkCopyDTO objLinkCopyDTO = new ObjLinkCopyDTO();
                objLinkCopyDTO.setTargetOid(((PartDO)targetParts.get(i)).getOid());
                objLinkCopyDTO.setSourceOid(((PartDO)sourceParts.get(i)).getOid());
                objLinkCopyDTO.setSourceBranchid(((PartDO)sourceParts.get(i)).getBranchid());
                objLinkCopyDTO.setTargetBranchid(((PartDO)targetParts.get(i)).getBranchid());
                partLinkCopyList.add(objLinkCopyDTO);
                CopyDTO copyDTO = new CopyDTO();
                copyDTO.setSrcOid(((PartDO)sourceParts.get(i)).getOid());
                copyDTO.setSrcOtype(((PartDO)sourceParts.get(i)).getOtype());
                copyDTO.setTargetOid(((PartDO)targetParts.get(i)).getOid());
                copyDTO.setTargetOtype(((PartDO)targetParts.get(i)).getOtype());
                copyDTOS.add(copyDTO);
            }

            this.typlmPartIteratorService.fullCopyAttrs(sourceParts, new ArrayList(targetParts), paramDTO);
            this.typlmEntityAdHocService.batchCopyDynamicAccess(copyDTOS);
            this.typlmExecutePartImportExtensionUtil.copyPartLinkAttr(partLinkCopyList);
        }
    }

    private void copyAttr(PartXmlGlobeNodeDTO globeNodeDTO, Map<PartDO, PartDO> sourceAndTargetPartRel, Boolean copyUsageLink) {
        if (!CollectionUtils.isEmpty(sourceAndTargetPartRel)) {
            TyplmCopyAttrParamDTO copyAttrParamDTO = new TyplmCopyAttrParamDTO();
            copyAttrParamDTO.setCopyAttr(true);
            if (Boolean.TRUE.toString().equalsIgnoreCase(globeNodeDTO.getCopyDerivedimage())) {
                copyAttrParamDTO.setCopyPartAssociateLightWeight(true);
            }

            copyAttrParamDTO.setCopyDescribeCad(true);
            copyAttrParamDTO.setCopyUsageLink(false);
            if ("buildRule-Att".equalsIgnoreCase(globeNodeDTO.getPartLinkType()) || "buildRule-PartAtt".equalsIgnoreCase(globeNodeDTO.getPartLinkType()) || Boolean.TRUE.equals(copyUsageLink)) {
                copyAttrParamDTO.setCopyUsageLink(true);
            }

            copyAttrParamDTO.setCopyDescribeDoc(true);
            copyAttrParamDTO.setCopyReferenceDoc(true);
            if ("N".equalsIgnoreCase(globeNodeDTO.getCopydesc())) {
                copyAttrParamDTO.setCopyDescribeDoc(false);
            }

            if ("N".equalsIgnoreCase(globeNodeDTO.getCopyref())) {
                copyAttrParamDTO.setCopyReferenceDoc(false);
            }

            copyAttrParamDTO.setCopyMpnPartLink(true);
            copyAttrParamDTO.setCopyExtDataValue(true);
            copyAttrParamDTO.setCopyContentDataLink(true);
            copyAttrParamDTO.setCopyMarkup(true);
            copyAttrParamDTO.setAsync(false);
            copyAttrParamDTO.setCopyPartMpmLink(true);
            copyAttrParamDTO.setCopyEquivalenceLink(true);
            if (TyplmExcelDataCheckUtil.COPY_LINK_ATTR.contains(globeNodeDTO.getPartLinkType())) {
                copyAttrParamDTO.setCopyLinkAttr(true);
            }

            List<PartDO> sourcePartDoList = Convert.toList(PartDO.class, sourceAndTargetPartRel.keySet());
            List<PartDO> targetPartDoList = Convert.toList(PartDO.class, sourceAndTargetPartRel.values());
            log.info("=====>>>> batchImportDataToDB:  begin copyAttrs");
            this.copyAttrs(sourcePartDoList, targetPartDoList, copyAttrParamDTO);
            log.info("=====>>>> batchImportDataToDB:  end copyAttrs");
            Map<BigInteger, BigInteger> map = new HashMap();
            sourceAndTargetPartRel.forEach((k, v) -> {
                BigInteger var10000 = (BigInteger)map.put(k.getOid(), v.getOid());
            });
            log.info("=====>>>> batchImportDataToDB:  begin copyPartDerivedImage");
            this.typlmPartDerivedImageService.copyPartDerivedImage(map);
            log.info("=====>>>> batchImportDataToDB:  end copyPartDerivedImage");
        }

    }

    private void batchImportDataToDB(UserDO userDO, PartXmlGlobeNodeDTO globeNodeDTO, PartImportToDBDTO partImportToDBDTO, PartXmlAllNodeDTO partXmlAllNodeDTO, Map<String, MDAImportOutDocVo> docXmlIdMap, TyPartImportBasicListDTO importBasicListDTO, List<Map<ResponseCodeEnum, String[]>> exceptions, String isCadImport) {
        if (!ObjectUtils.isEmpty(partXmlAllNodeDTO) && !ObjectUtils.isEmpty(partImportToDBDTO)) {
            TimeInterval timeInterval = new TimeInterval();
            timeInterval.start();
            int partMasterNum = 0;
            int updatePartNum = 0;
            List<PartXmlNodeDTO> partList = partXmlAllNodeDTO.getPartList();
            Map<String, String> partAndName = new HashMap();
            if (CollUtil.isNotEmpty(partList)) {
                Iterator var14 = partList.iterator();

                while(var14.hasNext()) {
                    PartXmlNodeDTO part = (PartXmlNodeDTO)var14.next();
                    partAndName.put(part.getPartnumber(), part.getPartname());
                }
            }

            Map<BigInteger, String> partAoidAndNumMap = new HashMap();
            Map<BigInteger, String> partBoidAndNumMap = new HashMap();
            List<PartMasterDO> partMasterDOInsertList = partImportToDBDTO.getPartMasterDOInsertList();
            if (CollUtil.isNotEmpty(partMasterDOInsertList)) {
                log.info("=====>>>> batchImportDataToDB: begin batchInsertPartMasterDO");
                Iterator var17 = partMasterDOInsertList.iterator();

                while(var17.hasNext()) {
                    PartMasterDO partMasterDO = (PartMasterDO)var17.next();
                    partAoidAndNumMap.put(partMasterDO.getDefaultiteratedoid(), partMasterDO.getPartnumber());
                    partBoidAndNumMap.put(partMasterDO.getOid(), partMasterDO.getPartnumber());
                    String partNumber = partMasterDO.getPartnumber();
                    if (CollUtil.isNotEmpty(partAndName) && ObjectUtils.isNotEmpty(partNumber)) {
                        this.progressUtils.saveProgressInfo(this.progressUtils.buildProgressEnum(partXmlAllNodeDTO.getProgressBarId(), "正在创建零件对象: " + partNumber + "," + (String)partAndName.get(partNumber)));
                    }
                }

                partMasterNum = this.typlmPartMasterExtService.batchInsertPartMasterDO(partMasterDOInsertList);
                log.info("=====>>>> batchImportDataToDB: end batchInsertPartMasterDO:{}", timeInterval.interval());
                timeInterval.restart();
            }

            Map<BigInteger, JSONObject> branchMap = new HashMap();
            List<PartDO> newControlBranchPartDOList = partImportToDBDTO.getNewControlBranchPartDOList();
            if (CollUtil.isNotEmpty(newControlBranchPartDOList)) {
                log.info("=====>>>> batchImportDataToDB: begin batchNewBranchid");
                this.tyBranchidControlExtService.batchNewBranchid(new ArrayList(newControlBranchPartDOList));
                log.info("=====>>>> batchImportDataToDB: end batchNewBranchid:{}", timeInterval.interval());
                timeInterval.restart();
                branchMap = (Map)newControlBranchPartDOList.stream().collect(Collectors.toMap(PartDO::getBranchid, this::buildJson, (k1, k2) -> {
                    return k1;
                }));
                log.info("newControlBranchPartDOList buildJson :{}", timeInterval.interval());
                timeInterval.restart();
            }

            List<PartDO> partDOInsertList = partImportToDBDTO.getPartDOInsertList();
            if (CollUtil.isNotEmpty(partDOInsertList)) {
                log.info("=====>>>> batchImportDataToDB: begin batchInsertPartDO");
                this.typlmPartExtService.batchInsertPartDO(partDOInsertList);
                log.info("batchImportDataToDB size:{}", partDOInsertList.size());
                log.info("=====>>>> batchImportDataToDB: end batchInsertPartDO:{}", timeInterval.interval());
                timeInterval.restart();
                log.info("=====>>>> batchImportDataToDB: begin batchCreateLifecycleHistory");
                this.typlmMPMBomService.batchCreateLifecycleHistory(userDO.getOid(), partImportToDBDTO.getPartDOInsertList());
                log.info("=====>>>> batchImportDataToDB: end batchCreateLifecycleHistory:{}", timeInterval.interval());
                timeInterval.restart();
                partImportToDBDTO.getPartDOInsertList().forEach((item) -> {
                    this.typlmLogger.info(item, LogEventEnum.CRATE_OBJECT, Boolean.FALSE);
                });
            }

            List<InsertClassificationType> classificationList = partImportToDBDTO.getClassificationList();
            if (CollUtil.isNotEmpty(classificationList)) {
                log.info("=====>>>> batchImportDataToDB: begin batchInsertReferenceValue");
                this.typlmReferenceValueService.batchInsertReferenceValue(classificationList);
                log.info("=====>>>> batchImportDataToDB: end batchInsertReferenceValue:{}", timeInterval.interval());
                timeInterval.restart();
            }

            Map<BigInteger, String> linkOidAndNumMap = new HashMap();
            Map<BigInteger, String> masteroidAndNumMap = new HashMap();
            Map<BigInteger, String> oidAndNumMap = new HashMap();
            Map<BigInteger, String> linkOidAndNumCADMap = new HashMap();
            if (ObjectUtils.isNotEmpty(importBasicListDTO)) {
                this.buildNumMap(importBasicListDTO, linkOidAndNumMap, masteroidAndNumMap, oidAndNumMap, linkOidAndNumCADMap);
            }

            List<PartDO> partDOUpdateList = partImportToDBDTO.getPartDOUpdateList();
            if (CollUtil.isNotEmpty(partDOUpdateList)) {
                log.info("=====>>>> batchImportDataToDB: begin batchUpdatePartDOByPrimaryKey");

                PartDO partDO;
                for(Iterator var26 = partDOUpdateList.iterator(); var26.hasNext(); this.typlmLogger.info(partDO, LogEventEnum.UPDATE_OBJECT, Boolean.FALSE)) {
                    partDO = (PartDO)var26.next();
                    if (ObjectUtils.isNotEmpty(masteroidAndNumMap) && ObjectUtils.isNotEmpty(partAndName)) {
                        String partNumber = (String)masteroidAndNumMap.get(partDO.getMasteredoid());
                        if (ObjectUtils.isNotEmpty(partNumber)) {
                            this.progressUtils.saveProgressInfo(this.progressUtils.buildProgressEnum(partXmlAllNodeDTO.getProgressBarId(), "正在更新零件对象: " + partNumber + "," + (String)partAndName.get(partNumber)));
                        }
                    }
                }

                updatePartNum = this.typlmPartExtService.batchUpdatePartDOByPrimaryKey(partDOUpdateList);
                log.info("=====>>>> batchImportDataToDB: end batchUpdatePartDOByPrimaryKey:{}", timeInterval.interval());
                timeInterval.restart();
                ((Map)branchMap).putAll((Map)partDOUpdateList.stream().collect(Collectors.toMap(PartDO::getBranchid, this::buildJson, (k1, k2) -> {
                    return k1;
                })));
                log.info("partImportToDBDTO buildJson log info:{}", timeInterval.interval());
                timeInterval.restart();
            }

            List<PartDO> partDOUpdateWrkList = partImportToDBDTO.getPartDOUpdateWrkList();
            if (CollUtil.isNotEmpty(partDOUpdateWrkList)) {
                this.typlmEntityBaseService.batchUpdateWithCommit(partDOUpdateWrkList, true);
            }

            List<PartDO> allCheckinPart = partImportToDBDTO.getAllCheckinPart();
            Iterator var29;
            List partUsageLinkDOInsertList;
            if (CollUtil.isNotEmpty(allCheckinPart)) {
                log.info("=====>>>> batchImportDataToDB: begin batchCheckIn");
                partUsageLinkDOInsertList = CommonUtil.subObjectList(allCheckinPart, this.count);
                var29 = partUsageLinkDOInsertList.iterator();

                while(var29.hasNext()) {
                    List<PartDO> partDOS = (List)var29.next();
                    this.typlmIteratorService.batchCheckIn(new ArrayList(partDOS), userDO);
                }

                log.info("=====>>>> batchImportDataToDB: end batchCheckIn:{}", timeInterval.interval());
                timeInterval.restart();
                allCheckinPart.forEach((item) -> {
                    this.typlmLogger.info(item, LogEventEnum.CHECK_IN);
                });
            }

            TyAccountContext.setBizCommonHolderMapValue("newBranchId_key", Lists.newArrayList(((Map)branchMap).values()));
            TyAccountContext.setBizCommonHolderMapValue("saveAsPart_key", partImportToDBDTO.getSaveAsPartMap());
            TyAccountContext.setBizCommonHolderMapValue("downStreamPart_key", partImportToDBDTO.getDownStreamPartMap());
            TyAccountContext.setBizCommonHolderMapValue("saveAsStruct_key", partImportToDBDTO.getSaveAsPartStructMap());
            this.copyPartDescribeLink(partImportToDBDTO);
            log.info("=====>>>> batchImportDataToDB:  复制更新零件的关联关系 begin copyAttr");
            this.copyAttr(globeNodeDTO, partImportToDBDTO.getSourceAndTargetPartRel(), false);
            log.info("=====>>>> batchImportDataToDB:  复制更新零件的关联关系 end copyAttr:{}", timeInterval.interval());
            timeInterval.restart();
            this.copyAttr(globeNodeDTO, partImportToDBDTO.getSourceAndTargetPartRelCopyUsageLink(), true);
            log.info("针对dwg图纸明细表中零件需要强制复制上一个版本的结构:{}", timeInterval.interval());
            timeInterval.restart();

            PartTypeDefService partTypeDefService= SpringUtil.getBean(PartTypeDefService.class);
            if(partTypeDefService!=null){
                partTypeDefService.insertPartBefore(partImportToDBDTO.getPartFolderMemberLink());
            }

            this.batchInsertIterFolderMemberLink(partImportToDBDTO.getPartFolderMemberLink());
            log.info("批量创建零件和文件夹关系:{}", timeInterval.interval());
            this.copyPartSubstitute(partImportToDBDTO, globeNodeDTO);
            timeInterval.restart();
            this.typlmPartUsageLinkExtService.batchDeletePartUsageLinkReleated(partImportToDBDTO.getNeedDeleteParentOids());
            log.info("批量删除零件结构:{}", timeInterval.interval());
            timeInterval.restart();
            if (!CollectionUtils.isEmpty(partImportToDBDTO.getPartUsageLinkDOInsertList())) {
                partImportToDBDTO.getPartUsageLinkDOInsertList().forEach((usageLink) -> {
                    usageLink.setReference("");
                });
            }

            log.info("设置reference为空:{}", timeInterval.interval());
            timeInterval.restart();
            partUsageLinkDOInsertList = partImportToDBDTO.getPartUsageLinkDOInsertList();
            if (CollUtil.isNotEmpty(partUsageLinkDOInsertList)) {
                var29 = partUsageLinkDOInsertList.iterator();

                while(var29.hasNext()) {
                    PartUsageLinkDO partUsageLinkDO = (PartUsageLinkDO)var29.next();
                    BigInteger aoid = partUsageLinkDO.getAoid();
                    BigInteger boid = partUsageLinkDO.getBoid();
                    String parentPart = null;
                    String childPart = null;
                    if (ObjectUtils.isNotEmpty(linkOidAndNumMap)) {
                        parentPart = (String)linkOidAndNumMap.get(aoid);
                    } else if (ObjectUtils.isNotEmpty(partAoidAndNumMap)) {
                        parentPart = (String)partAoidAndNumMap.get(aoid);
                    }

                    if (ObjectUtils.isNotEmpty(masteroidAndNumMap)) {
                        childPart = (String)masteroidAndNumMap.get(boid);
                    } else if (ObjectUtils.isNotEmpty(partBoidAndNumMap)) {
                        childPart = (String)partBoidAndNumMap.get(boid);
                    }

                    if (childPart == null && ObjectUtils.isNotEmpty(oidAndNumMap)) {
                        childPart = (String)oidAndNumMap.get(boid);
                    }

                    if (ObjectUtils.isNotEmpty(partAndName) && ObjectUtils.isNotEmpty(childPart) && ObjectUtils.isNotEmpty(parentPart)) {
                        this.progressUtils.saveProgressInfo(this.progressUtils.buildProgressEnum(partXmlAllNodeDTO.getProgressBarId(), "正在创建零部件:" + parentPart + "," + (String)partAndName.get(parentPart) + "与零部件:" + childPart + "," + (String)partAndName.get(childPart) + "的关系"));
                    }
                }

                log.info("批量新增零件结构 size:{}", partUsageLinkDOInsertList.size());
                this.typlmPartUsageLinkService.batchInsertPartUsageLink(partUsageLinkDOInsertList);
                log.info("批量新增零件结构:{}", timeInterval.interval());
            }

            timeInterval.restart();
            this.typlmPartUsageLinkService.batchInsertPartUsesOccurrence(partImportToDBDTO.getPartUsesOccurrenceDOInsertList());
            log.info("批量保存位号:{}", timeInterval.interval());
            timeInterval.restart();
            this.batchSaveIba(partImportToDBDTO, partAndName, exceptions);
            log.info("批量保存IBA属性:{}", timeInterval.interval());
            this.throwException(exceptions, isCadImport, partImportToDBDTO, partXmlAllNodeDTO, docXmlIdMap, partAndName);
            timeInterval.restart();
            List<PdmCadBuildRuleVO> cadPartRuleBuildLink = null;
            if (!CollectionUtils.isEmpty(partImportToDBDTO.getCadBuildRuleDTOList())) {
                cadPartRuleBuildLink = this.typlmCadRuleBuildService.createCadPartRuleBuildLink(partImportToDBDTO.getCadBuildRuleDTOList());
            }

            Map<String, String> docOidAndNamecode = new HashMap();
            if (ObjectUtils.isNotEmpty(docXmlIdMap)) {
                Iterator var49 = docXmlIdMap.entrySet().iterator();

                while(var49.hasNext()) {
                    Map.Entry<String, MDAImportOutDocVo> entry = (Map.Entry)var49.next();
                    MDAImportOutDocVo value = (MDAImportOutDocVo)entry.getValue();
                    if (ObjectUtils.isNotEmpty(value)) {
                        docOidAndNamecode.put(value.getDocId(), value.getCode() + "," + value.getName());
                    }
                }
            }

            if (cadPartRuleBuildLink != null) {
                Map<BigInteger, BigInteger> cadOidAndPartoid = new HashMap();
                Iterator var52 = cadPartRuleBuildLink.iterator();

                while(var52.hasNext()) {
                    PdmCadBuildRuleVO pdmCadBuildRuleVO = (PdmCadBuildRuleVO)var52.next();
                    cadOidAndPartoid.put(pdmCadBuildRuleVO.getCadOid(), pdmCadBuildRuleVO.getPartOid());
                }

                if (ObjectUtils.isNotEmpty(cadOidAndPartoid)) {
                    var52 = cadOidAndPartoid.entrySet().iterator();

                    while(var52.hasNext()) {
                        Map.Entry<BigInteger, BigInteger> entry = (Map.Entry)var52.next();
                        BigInteger cadOid = (BigInteger)entry.getKey();
                        BigInteger partOid = (BigInteger)entry.getValue();
                        if (ObjectUtils.isNotEmpty(linkOidAndNumCADMap) && ObjectUtils.isNotEmpty(partAndName) && ObjectUtils.isNotEmpty(docOidAndNamecode)) {
                            String partNumber = (String)linkOidAndNumCADMap.get(partOid);
                            if (ObjectUtils.isNotEmpty(partNumber)) {
                                String progressInfo = "正在创建零件:" + partNumber + "," + (String)partAndName.get(partNumber) + "与CAD文档:" + (String)docOidAndNamecode.get(String.valueOf(cadOid)) + "的关系";
                                this.progressUtils.saveProgressInfo(this.progressUtils.buildProgressEnum(partXmlAllNodeDTO.getProgressBarId(), progressInfo));
                            }
                        }
                    }
                }
            }

            log.info("cad文档批量录入需要创建与零件的构建关系:{}", timeInterval.interval());
            timeInterval.restart();
            this.batchInsertCadPartBuildHistory(partImportToDBDTO, cadPartRuleBuildLink, docOidAndNamecode, linkOidAndNumMap, partAndName, partXmlAllNodeDTO);
            log.info("处理图纸、部件构建历史记录:{}", timeInterval.interval());
            timeInterval.restart();
            this.batchInsertWorkspaceLinkPart(partImportToDBDTO, userDO);
            log.info("处理零部件与工作区关系:{}", timeInterval.interval());
            timeInterval.restart();
            if (!CollectionUtils.isEmpty(partImportToDBDTO.getCadDescribeDOList())) {
                this.typlmCADDescLinkService.batchInsertCadDescLinkDO(partImportToDBDTO.getCadDescribeDOList());
                log.info("batchInsertCadDescLinkDO:{}", timeInterval.interval());
                timeInterval.restart();
            }

            this.buildSumNum(partMasterNum, updatePartNum, partImportToDBDTO, partXmlAllNodeDTO);
        }
    }

    protected void copyPartSubstitute(PartImportToDBDTO partImportToDBDTO, PartXmlGlobeNodeDTO globeNodeDTO) {
        if (!TyplmExcelDataCheckUtil.COPY_LINK_ATTR.contains(globeNodeDTO.getPartLinkType())) {
            Map<PartDO, PartDO> sourceAndTargetPartRel = partImportToDBDTO.getSourceAndTargetPartRel();
            if (!ObjectUtils.isEmpty(sourceAndTargetPartRel)) {
                List<PartDO> sourcePartDOList = Convert.toList(PartDO.class, sourceAndTargetPartRel.keySet());
                if (!CollUtil.isEmpty(sourcePartDOList)) {
                    List<BigInteger> aoidList = new ArrayList();
                    Iterator var6 = sourcePartDOList.iterator();

                    while(var6.hasNext()) {
                        PartDO partDO = (PartDO)var6.next();
                        if (!ObjectUtils.isEmpty(partDO)) {
                            aoidList.add(partDO.getOid());
                        }
                    }

                    if (CollUtil.isNotEmpty(partImportToDBDTO.getNeedDeleteParentOids())) {
                        aoidList.addAll(partImportToDBDTO.getNeedDeleteParentOids());
                    }

                    if (!CollUtil.isEmpty(aoidList)) {
                        List<PartUsageLinkDO> partUsageLinkDOS = new ArrayList();
                        List<List<BigInteger>> queryList = CollUtil.split(CollUtil.distinct(aoidList), 1000);
                        Iterator var8 = queryList.iterator();

                        while(var8.hasNext()) {
                            List<BigInteger> aoidSplit = (List)var8.next();
                            Example example = new Example(PartUsageLinkDO.class, true, true);
                            Example.Criteria criteria = example.createCriteria();
                            criteria.andIn("aoid", aoidSplit);
                            partUsageLinkDOS.addAll(this.typlmPartUsageLinkMapper.selectByExample(example));
                        }

                        if (!CollUtil.isEmpty(partUsageLinkDOS) && !CollUtil.isEmpty(partImportToDBDTO.getPartUsageLinkDOInsertList())) {
                            Map<String, PartUsageLinkDO> refoidMap = new HashMap();
                            Iterator var21 = partImportToDBDTO.getPartUsageLinkDOInsertList().iterator();

                            while(var21.hasNext()) {
                                PartUsageLinkDO partUsageLinkDO = (PartUsageLinkDO)var21.next();
                                refoidMap.put(partUsageLinkDO.getAoid() + "&" + partUsageLinkDO.getBoid() + "&" + partUsageLinkDO.getValue(), partUsageLinkDO);
                            }

                            if (!ObjectUtils.isEmpty(refoidMap)) {
                                Map<BigInteger, BigInteger> sourceAndTargetPartOidMap = new HashMap();
                                Iterator var24 = sourceAndTargetPartRel.entrySet().iterator();

                                BigInteger newAoid;
                                while(var24.hasNext()) {
                                    Map.Entry<PartDO, PartDO> partDOPartDOEntry = (Map.Entry)var24.next();
                                    PartDO key = (PartDO)partDOPartDOEntry.getKey();
                                    PartDO value = (PartDO)partDOPartDOEntry.getValue();
                                    newAoid = key.getOid();
                                    BigInteger targetPartOid = value.getOid();
                                    if (Objects.nonNull(newAoid) && Objects.nonNull(targetPartOid)) {
                                        sourceAndTargetPartOidMap.put(newAoid, targetPartOid);
                                    }
                                }

                                if (!ObjectUtils.isEmpty(sourceAndTargetPartOidMap)) {
                                    List<PartSubstituteCopyParamDTO> copyDataDTOList = new ArrayList();
                                    Iterator var27 = partUsageLinkDOS.iterator();

                                    while(var27.hasNext()) {
                                        PartUsageLinkDO obj = (PartUsageLinkDO)var27.next();
                                        PartSubstituteCopyParamDTO partSubstituteCopyParamDTO = new PartSubstituteCopyParamDTO();
                                        newAoid = (BigInteger)Optional.ofNullable(sourceAndTargetPartOidMap.get(obj.getAoid())).orElse(obj.getAoid());
                                        String key = newAoid + "&" + obj.getBoid() + "&" + obj.getValue();
                                        PartUsageLinkDO partUsageLinkDO = (PartUsageLinkDO)refoidMap.get(key);
                                        if (ObjectUtil.isNotEmpty(partUsageLinkDO)) {
                                            BigInteger targerOid = partUsageLinkDO.getOid();
                                            partSubstituteCopyParamDTO.setSourcePartLinkOid(obj.getOid());
                                            if (ObjectUtil.isNotEmpty(partSubstituteCopyParamDTO)) {
                                                partSubstituteCopyParamDTO.setTargetPartLinkOid(targerOid);
                                                copyDataDTOList.add(partSubstituteCopyParamDTO);
                                            }
                                        }
                                    }

                                    if (CollUtil.isNotEmpty(copyDataDTOList)) {
                                        this.typlmPartSubstituteSaveService.copyPartSubstitute(copyDataDTOList);
                                    }

                                }
                            }
                        }
                    }
                }
            }
        }
    }

    private void buildSumNum(int partMasterNum, int updatePartNum, PartImportToDBDTO partImportToDBDTO, PartXmlAllNodeDTO partXmlAllNodeDTO) {
        if (!ObjectUtils.isEmpty(partImportToDBDTO)) {
            StringBuilder builderNum = new StringBuilder("【零部件对象创建完成】");
            if (partMasterNum != 0) {
                builderNum.append(String.format(" : 已创建%s个零件对象", partMasterNum));
            }

            if (updatePartNum != 0) {
                builderNum.append(String.format("；已更新%s个零件对象", updatePartNum));
            }

            if (CollUtil.isNotEmpty(partImportToDBDTO.getPartUsageLinkDOInsertList())) {
                builderNum.append(String.format("；已创建%s个零部件与零部件的关系", partImportToDBDTO.getPartUsageLinkDOInsertList().size()));
            }

            if (CollUtil.isNotEmpty(partImportToDBDTO.getCadBuildRuleDTOList())) {
                builderNum.append(String.format("；已创建%s个图纸与零部件的关系", partImportToDBDTO.getCadBuildRuleDTOList().size()));
            } else if (CollUtil.isNotEmpty(partImportToDBDTO.getCadBuildHistoryDTOList())) {
                builderNum.append(String.format("；已创建%s个图纸与零部件的关系", partImportToDBDTO.getCadBuildHistoryDTOList().size()));
            }

            builderNum.append("。");
            if (ObjectUtils.isNotEmpty(builderNum)) {
                this.progressUtils.saveProgressInfo(this.progressUtils.buildProgressEnum(partXmlAllNodeDTO.getProgressBarId(), builderNum.toString()));
            }

        }
    }

    private void batchInsertWorkspaceLinkPart(PartImportToDBDTO partImportToDBDTO, UserDO userDO) {
        List<PartImportBuildHistoryDTO> cadBuildHistoryDTOList = partImportToDBDTO.getCadBuildHistoryDTOList();
        ImportWorkSpaceDTO workSpace = partImportToDBDTO.getWorkSpace();
        if (!CollectionUtils.isEmpty(cadBuildHistoryDTOList) && !Objects.isNull(workSpace)) {
            List<BigInteger> cadIdList = (List)cadBuildHistoryDTOList.stream().map(PartImportBuildHistoryDTO::getCadId).collect(Collectors.toList());
            List<CADWorkspaceVO> cadWorkspaceVOS = this.tyPlmDefaultWorkspaceService.queryAllWorkspaceByObjOidList(cadIdList);
            if (!CollUtil.isEmpty(cadWorkspaceVOS)) {
                Map<String, List<String>> cadWorkspaceIdMap = (Map)cadWorkspaceVOS.stream().collect(Collectors.toMap(CADWorkspaceVO::getObjOid, (s) -> {
                    return (List<String>)Lists.newArrayList(new String[]{s.getWorkSpaceOid()});
                }, ListUtils::union));
                WorkspaceOperateDTO workspaceOperateDTO = new WorkspaceOperateDTO();
                workspaceOperateDTO.setWorkspaceOid(new BigInteger(workSpace.getNetWorkspaceId()));
                workspaceOperateDTO.setUserOid(userDO.getOid());
                List<WorkspaceMemberVO> partList = new ArrayList();
                Iterator var10 = cadBuildHistoryDTOList.iterator();

                while(var10.hasNext()) {
                    PartImportBuildHistoryDTO historyDTO = (PartImportBuildHistoryDTO)var10.next();
                    BigInteger cadId = historyDTO.getCadId();
                    BigInteger partId = historyDTO.getPartId();
                    List<String> list = (List)cadWorkspaceIdMap.get(String.valueOf(cadId));
                    if (CollUtil.isNotEmpty(list) && list.contains(workSpace.getNetWorkspaceId())) {
                        WorkspaceMemberVO vo = new WorkspaceMemberVO();
                        vo.setOid(String.valueOf(partId));
                        vo.setOtype("ty.inteplm.part.CTyPart");
                        partList.add(vo);
                    }
                }

                if (CollUtil.isNotEmpty(partList)) {
                    workspaceOperateDTO.setObjList(partList);
                    this.typlmSdkWorkspaceService.addToWorkSpace(workspaceOperateDTO);
                }

            }
        }
    }

    private void batchSaveIba(PartImportToDBDTO partImportToDBDTO, Map<String, String> partAndName, List<Map<ResponseCodeEnum, String[]>> exceptions) {
        Map<BigInteger, String> oidAndNumNameMap = new HashMap();
        Map<BigInteger, BigInteger> partusageoidAndMasterOid = new HashMap();
        ArrayList objWithIbaInsertList;
        List ibaList;
        List structIbaInsertList;
        if (ObjectUtils.isNotEmpty(partImportToDBDTO)) {
            objWithIbaInsertList = new ArrayList();
            ibaList = partImportToDBDTO.getPartDOInsertList();
            structIbaInsertList = partImportToDBDTO.getPartDOUpdateList();
            List<PartUsageLinkDO> partUsageLinkDOInsertList = partImportToDBDTO.getPartUsageLinkDOInsertList();
            Iterator var10 = partUsageLinkDOInsertList.iterator();

            BigInteger masteredoid;
            BigInteger oid;
            while(var10.hasNext()) {
                PartUsageLinkDO partUsageLinkDO = (PartUsageLinkDO)var10.next();
                masteredoid = partUsageLinkDO.getOid();
                oid = partUsageLinkDO.getBoid();
                if (masteredoid != null && oid != null) {
                    partusageoidAndMasterOid.put(masteredoid, oid);
                }
            }

            objWithIbaInsertList.addAll(ibaList);
            objWithIbaInsertList.addAll(structIbaInsertList);
            if (ObjectUtils.isNotEmpty(objWithIbaInsertList) && ObjectUtils.isNotEmpty(partAndName)) {
                var10 = objWithIbaInsertList.iterator();

                while(var10.hasNext()) {
                    PartDO partDO = (PartDO)var10.next();
                    masteredoid = partDO.getMasteredoid();
                    oid = partDO.getOid();
                    String partNumber = partDO.getPartnumber();
                    if (ObjectUtils.isNotEmpty(oid) && StringUtils.isNotBlank(partNumber)) {
                        String partNumberName = partNumber + "," + (String)partAndName.get(partNumber);
                        oidAndNumNameMap.put(oid, partNumberName);
                        oidAndNumNameMap.put(masteredoid, partNumberName);
                    }
                }
            }
        }

        objWithIbaInsertList = new ArrayList();
        ibaList = partImportToDBDTO.getIbaBeanDTOInsertList();
        if (!CollectionUtils.isEmpty(ibaList)) {
            this.getIbaList(ibaList, objWithIbaInsertList);
        }

        structIbaInsertList = partImportToDBDTO.getPartStructIbaBeanDTOInsertList();
        if (!CollectionUtils.isEmpty(structIbaInsertList)) {
            this.getIbaList(structIbaInsertList, objWithIbaInsertList);
        }

        if (!CollectionUtils.isEmpty(objWithIbaInsertList)) {
            this.saveIba(objWithIbaInsertList, oidAndNumNameMap, partusageoidAndMasterOid, exceptions, true);
        }

        List<SaveObjIBADTO> objWithIbaUpdateList = new ArrayList();
        List<PartImportIbaBeanDTO> ibaUpdateList = partImportToDBDTO.getIbaBeanDTOUpdateList();
        if (!CollectionUtils.isEmpty(ibaUpdateList)) {
            this.getIbaList(ibaUpdateList, objWithIbaUpdateList);
        }

        if (!CollectionUtils.isEmpty(objWithIbaUpdateList)) {
            this.saveIba(objWithIbaUpdateList, oidAndNumNameMap, partusageoidAndMasterOid, exceptions, false);
        }

    }

    private void saveIba(List<SaveObjIBADTO> objWithIbaList, Map<BigInteger, String> oidAndNumNameMap, Map<BigInteger, BigInteger> partusageoidAndMasterOid, List<Map<ResponseCodeEnum, String[]>> exceptions, boolean isCreatAction) {
        this.typlmAttributeValueService.batchSaveIBAByObjList(objWithIbaList, oidAndNumNameMap, partusageoidAndMasterOid, exceptions, isCreatAction);
    }

    private void getIbaList(List<PartImportIbaBeanDTO> ibaBeanDTOS, List<SaveObjIBADTO> objWithIbaList) {
        if (!CollectionUtils.isEmpty(ibaBeanDTOS)) {
            Iterator var3 = ibaBeanDTOS.iterator();

            while(var3.hasNext()) {
                PartImportIbaBeanDTO iba = (PartImportIbaBeanDTO)var3.next();
                if (Objects.nonNull(iba)) {
                    SaveObjIBADTO saveObjIBADTO = new SaveObjIBADTO();
                    saveObjIBADTO.setCTyEntityBaseDO(iba.getEntityBaseDO());
                    saveObjIBADTO.setObjIbaList(iba.getIbas());
                    objWithIbaList.add(saveObjIBADTO);
                }
            }
        }

    }

    private void batchInsertCadPartBuildHistory(PartImportToDBDTO partImportToDBDTO, List<PdmCadBuildRuleVO> cadPartRuleBuildLink, Map<String, String> docOidAndNamecode, Map<BigInteger, String> linkOidAndNumMap, Map<String, String> partAndName, PartXmlAllNodeDTO partXmlAllNodeDTO) {
        List<BigInteger> hadHistoryPartIdList = new ArrayList();
        this.insertBuildRuleHistoryCadPartVersion(partImportToDBDTO.getCadBuildHistoryDTOList(), cadPartRuleBuildLink, hadHistoryPartIdList, docOidAndNamecode, linkOidAndNumMap, partAndName, partXmlAllNodeDTO);
        this.insertBuildRuleHistoryByPartNotVersion(partImportToDBDTO.getNoRightBuildRuleDTOList(), hadHistoryPartIdList);
        this.insertBuildRuleHistoryCadPartNotVersion(partImportToDBDTO, hadHistoryPartIdList);
    }

    private void insertBuildRuleHistoryByPartNotVersion(List<CadBuildRuleDTO> noRightBuildRuleDOList, List<BigInteger> hadHistoryPartIdList) {
        if (!CollUtil.isEmpty(noRightBuildRuleDOList)) {
            List<BigInteger> cadIdList = (List)noRightBuildRuleDOList.stream().map(CadBuildRuleDTO::getAoid).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(cadIdList)) {
                List<CADBuildHistoryDO> cadBuildHistoryDOS = this.typlmcadBuildHistoryService.batchQueryCADLinkLastedPartByLastVersion(cadIdList);
                if (!CollUtil.isEmpty(cadBuildHistoryDOS)) {
                    List<CadBuildHistoryDTO> list = new ArrayList();
                    Iterator var6 = cadBuildHistoryDOS.iterator();

                    while(var6.hasNext()) {
                        CADBuildHistoryDO historyDO = (CADBuildHistoryDO)var6.next();
                        CadBuildHistoryDTO historyDTO = new CadBuildHistoryDTO();
                        historyDTO.setCadId(historyDO.getAoid());
                        historyDTO.setPartId(historyDO.getBoid());
                        historyDTO.setBuildRuleId(historyDO.getBuildruleid());
                        historyDTO.setBuildtype(historyDO.getBuildtype());
                        list.add(historyDTO);
                        hadHistoryPartIdList.add(historyDTO.getPartId());
                    }

                    this.typlmcadBuildHistoryService.batchInsert(list);
                }
            }
        }
    }

    private void insertBuildRuleHistoryCadPartNotVersion(PartImportToDBDTO partImportToDBDTO, List<BigInteger> hadHistoryPartIdList) {
        List<PartDO> sourcePartList = partImportToDBDTO.getPartDOInsertList();
        if (!CollUtil.isEmpty(sourcePartList)) {
            List<ObjLinkCopyDTO> partLinkCopyList = new ArrayList();
            Iterator var5 = sourcePartList.iterator();

            while(var5.hasNext()) {
                PartDO partDO = (PartDO)var5.next();
                if (!hadHistoryPartIdList.contains(partDO.getOid())) {
                    ObjLinkCopyDTO copyDTO = new ObjLinkCopyDTO();
                    copyDTO.setSourceOid(partDO.getSourceiterationoid());
                    copyDTO.setSourceBranchid(partDO.getBranchid());
                    copyDTO.setSourceMasterOid(partDO.getMasteredoid());
                    copyDTO.setTargetOid(partDO.getOid());
                    copyDTO.setTargetBranchid(partDO.getBranchid());
                    copyDTO.setTargetMasterOid(partDO.getMasteredoid());
                    partLinkCopyList.add(copyDTO);
                }
            }

            this.typlmcadBuildHistoryService.copyPartObjHistory(partLinkCopyList);
        }
    }

    private void insertBuildRuleHistoryCadPartVersion(List<PartImportBuildHistoryDTO> cadPartRuleBuildHistory, List<PdmCadBuildRuleVO> cadPartRuleBuildLink, List<BigInteger> hadHistoryPartIdList, Map<String, String> docOidAndNamecode, Map<BigInteger, String> linkOidAndNumMap, Map<String, String> partAndName, PartXmlAllNodeDTO partXmlAllNodeDTO) {
        if (!CollUtil.isEmpty(cadPartRuleBuildHistory)) {
            Iterator var8 = cadPartRuleBuildHistory.iterator();

            BigInteger buildRuleId;
            while(var8.hasNext()) {
                PartImportBuildHistoryDTO partImportBuildHistoryDTO = (PartImportBuildHistoryDTO)var8.next();
                if (ObjectUtils.isNotEmpty(partImportBuildHistoryDTO.getBuildRuleId()) && ObjectUtils.isNotEmpty(linkOidAndNumMap)) {
                    String partNumber = (String)linkOidAndNumMap.get(partImportBuildHistoryDTO.getPartId());
                    buildRuleId = partImportBuildHistoryDTO.getCadId();
                    if (ObjectUtils.isNotEmpty(partNumber) && ObjectUtils.isNotEmpty(buildRuleId) && ObjectUtils.isNotEmpty(partAndName) && ObjectUtils.isNotEmpty(docOidAndNamecode)) {
                        String progressInfo = "正在创建零件:" + partNumber + "," + (String)partAndName.get(partNumber) + "与CAD文档:" + (String)docOidAndNamecode.get(String.valueOf(buildRuleId)) + "的关系";
                        this.progressUtils.saveProgressInfo(this.progressUtils.buildProgressEnum(partXmlAllNodeDTO.getProgressBarId(), progressInfo));
                    }
                }
            }

            Map<String, BigInteger> cadPartBuildRuleMap = new ArrayHashMap();
            Iterator var14;
            if (CollUtil.isNotEmpty(cadPartRuleBuildLink)) {
                var14 = cadPartRuleBuildLink.iterator();

                while(var14.hasNext()) {
                    PdmCadBuildRuleVO buildRuleVO = (PdmCadBuildRuleVO)var14.next();
                    cadPartBuildRuleMap.put(buildRuleVO.getCadOid() + String.valueOf(buildRuleVO.getPartOid()), buildRuleVO.getBuildRuleOid());
                }
            }

            PartImportBuildHistoryDTO historyDTO;
            for(var14 = cadPartRuleBuildHistory.iterator(); var14.hasNext(); hadHistoryPartIdList.add(historyDTO.getPartId())) {
                historyDTO = (PartImportBuildHistoryDTO)var14.next();
                if (Objects.isNull(historyDTO.getBuildRuleId())) {
                    buildRuleId = (BigInteger)cadPartBuildRuleMap.get(historyDTO.getCadId() + String.valueOf(historyDTO.getPartId()));
                    historyDTO.setBuildRuleId(buildRuleId);
                }
            }

            this.typlmcadBuildHistoryService.batchInsert(ConvertUtils.sourceToTarget(cadPartRuleBuildHistory, CadBuildHistoryDTO.class));
        }
    }

    private void batchInsertIterFolderMemberLink(List<PartDO> partDOList) {
        if (!CollectionUtils.isEmpty(partDOList)) {
            List<IterFolderMemberLinkDO> insertList = new CopyOnWriteArrayList();
            partDOList.parallelStream().forEach((partDO) -> {
                IterFolderMemberLinkDO iterFolderMemberLinkDO = new IterFolderMemberLinkDO();
                if (ObjectUtils.compare(partDO.getSubfolderoid(), BigInteger.ZERO, false) > 0) {
                    iterFolderMemberLinkDO.setAoid(partDO.getSubfolderoid());
                    iterFolderMemberLinkDO.setAotype("ty.inteplm.folder.CTySubFolder");
                } else {
                    iterFolderMemberLinkDO.setAoid(partDO.getCabinetoid());
                    iterFolderMemberLinkDO.setAotype(partDO.getCabinetotype());
                }

                iterFolderMemberLinkDO.setBoid((BigInteger)null);
                iterFolderMemberLinkDO.setBotype("ty.inteplm.part.CTyPart");
                iterFolderMemberLinkDO.setOid(this.snowflakeIdComponent.getInstance().nextId());
                iterFolderMemberLinkDO.setOtype("ty.inteplm.folder.CTyIteratedFolderMemberLink");
                iterFolderMemberLinkDO.setBranchid(partDO.getBranchid());
                Date newDate = new Date();
                iterFolderMemberLinkDO.setCreatestamp(newDate);
                iterFolderMemberLinkDO.setUpdatestamp(newDate);
                iterFolderMemberLinkDO.setUpdatecount(0L);
                iterFolderMemberLinkDO.setLatesta(BigInteger.ONE);
                iterFolderMemberLinkDO.setMarkfordelete(0L);
                insertList.add(iterFolderMemberLinkDO);
            });
            this.typlmIterFolderMemberLinkService.batchInsertIterFolderMemberLink(insertList);
        }
    }

    private JSONObject buildJson(PartDO part) {
        JSONObject json = new JSONObject();
        json.put("branchid", part.getBranchid());
        json.put("masteredoid", part.getMasteredoid());
        json.put("oid", part.getOid());
        json.put("otype", part.getOtype());
        return json;
    }

    private PartImportToDBDTO newPartMaster(TyPartImportBasicListDTO importBasicListDTO, UserDO userDO, Map<String, List<PartImportLogVO>> returnLogMap) {
        TyplmLoggerUtil.debug(log, () -> {
            return "newPartMaster ==> begin newPartMaster";
        });
        PartImportToDBDTO partImportToDBDTO = new PartImportToDBDTO();
        Map<String, PartDO> allNewMasterNumberMap = new HashMap();
        Map<String, PartMasterDO> allNewMasterNumberMasterMap = new HashMap();
        Map<BigInteger, PartMasterDO> partMasterDOMap = new HashMap();
        List<PartDO> partDOList = new ArrayList();
        Collection<String> allNewMasterNumberList = importBasicListDTO.getAllNewMasterNumberList();
        TyplmLoggerUtil.debug(log, () -> {
            return "newPartMaster ==> allNewMasterNumberList = 【{}】";
        }, () -> {
            return new Object[]{allNewMasterNumberList};
        });
        Iterator var10 = allNewMasterNumberList.iterator();

        while(var10.hasNext()) {
            String partnumber = (String)var10.next();
            PartXmlNodeDTO partXmlNodeDTO = (PartXmlNodeDTO)importBasicListDTO.getPartNumberMap().get(partnumber);
            ViewDefDO viewDefDO = (ViewDefDO)importBasicListDTO.getAllViewDefDOMap().get(partXmlNodeDTO.getView());
            CTyEntityBaseDO foldeEntityBase = this.typlmPartBomImportCheckUtil.getFoldeEntityBase(partnumber, importBasicListDTO);
            PartMasterDO masterDo = new PartMasterDO();
            masterDo.setName(partXmlNodeDTO.getPartname());
            masterDo.setPartnumber(partXmlNodeDTO.getPartnumber());
            String parttype;
            Map allPartTypeRelDTOMap;
            if ("saveAs".equalsIgnoreCase(importBasicListDTO.getIsCadImport())) {
                masterDo.setGenerictype(partXmlNodeDTO.getGenerictype());
                if (StringUtils.isNotEmpty(partXmlNodeDTO.getCollapsible())) {
                    masterDo.setCollapsible(Long.valueOf(partXmlNodeDTO.getCollapsible()));
                }
            } else {
                Map<String, String> generictypeMap = importBasicListDTO.getGenerictypeMap();
                parttype = this.typlmPartBomImportUtil.getEnumName("GenericTypeEnum", generictypeMap, partXmlNodeDTO.getGenerictype(), importBasicListDTO);
                masterDo.setGenerictype(parttype);
                allPartTypeRelDTOMap = importBasicListDTO.getCollapsibleMap();
                String collapsible = this.typlmPartBomImportUtil.getEnumName("CollapsibleEnum", allPartTypeRelDTOMap, partXmlNodeDTO.getCollapsible(), importBasicListDTO);
                if (StringUtils.isNotEmpty(collapsible)) {
                    masterDo.setCollapsible(Long.valueOf(collapsible));
                }
            }

            this.typlmPartBomImportUtil.setPartMasterAttr(masterDo, partXmlNodeDTO.getDefaultunit(), partXmlNodeDTO.getIsvirtual(), partXmlNodeDTO.getIsenditem(), importBasicListDTO);
            PartDO partDO = new PartDO();
            this.typlmPartBomImportUtil.setPartAttr(partDO, masterDo, userDO.getOid(), viewDefDO);
            this.typlmPartBomImportUtil.setPartFolder(partDO, foldeEntityBase);
            parttype = partXmlNodeDTO.getParttypedefname();
            allPartTypeRelDTOMap = importBasicListDTO.getAllPartTypeRelDTOMap();
            Map<String, TySeriesOutDTO> allTypeSeriesOutDTOMap = importBasicListDTO.getAllTypeSeriesOutDTOMap();
            if (!CollectionUtils.isEmpty(allPartTypeRelDTOMap) && !CollectionUtils.isEmpty(allTypeSeriesOutDTOMap)) {
                List<PartTypeRelDTO> partTypeRelDTOS = (List)allPartTypeRelDTOMap.get(parttype);
                TySeriesOutDTO tySeriesOutDTO = (TySeriesOutDTO)allTypeSeriesOutDTOMap.get(partnumber);
                Map<String, String> numberVersionMap = new HashMap();
                Iterator var23 = partTypeRelDTOS.iterator();

                while(var23.hasNext()) {
                    PartTypeRelDTO partTypeRelDTO = (PartTypeRelDTO)var23.next();
                    if (ObjectUtils.isNotEmpty(partTypeRelDTO) && ObjectUtils.isNotEmpty(tySeriesOutDTO)) {
                        String partNumber = partTypeRelDTO.getPartNumber();
                        String version = partTypeRelDTO.getUserSetVersion() != null ? partTypeRelDTO.getUserSetVersion() : tySeriesOutDTO.getVersion();
                        if (StringUtils.isNotBlank(partNumber) && StringUtils.isNotBlank(version)) {
                            numberVersionMap.put(partNumber, version);
                        }

                        partDO.setIterationid(tySeriesOutDTO.getIterationid());
                        partDO.setVersionsort(tySeriesOutDTO.getSortid());
                        masterDo.setSeries(tySeriesOutDTO.getSeriesName());
                    }
                }

                if (ObjectUtils.isNotEmpty(numberVersionMap)) {
                    partDO.setVersion((String)numberVersionMap.get(partnumber));
                }
            }

            if (!CollectionUtils.isEmpty(importBasicListDTO.getAllTypeDOMap())) {
                TypeDO typeDO = (TypeDO)importBasicListDTO.getAllTypeDOMap().get(parttype);
                if (Objects.nonNull(typeDO)) {
                    partDO.setTypeoid(typeDO.getOid());
                    partDO.setTypeotype(typeDO.getOtype());
                }
            }

            partDO.setPartnumber(partnumber);
            partMasterDOMap.put(partDO.getOid(), masterDo);
            partDOList.add(partDO);
        }

        this.typlmCompanyVersionService.batchInitCompanyVersionInfo(partDOList);
        var10 = partDOList.iterator();

        while(var10.hasNext()) {
            PartDO partDO = (PartDO)var10.next();
            BigInteger key = partDO.getOid();
            PartMasterDO masterDo = (PartMasterDO)partMasterDOMap.get(key);
            PartXmlNodeDTO partXmlNodeDTO = (PartXmlNodeDTO)importBasicListDTO.getPartNumberMap().get(partDO.getPartnumber());
            if (!"saveAs".equalsIgnoreCase(importBasicListDTO.getIsCadImport())) {
                this.typlmPartBomImportUtil.setPartEnumAttr(partDO, partXmlNodeDTO, importBasicListDTO, false);
            } else {
                partDO.setSourcekey(partXmlNodeDTO.getSource());
                partDO.setSecuritylabels(partXmlNodeDTO.getSecurity());
                partDO.setParttypekey(partXmlNodeDTO.getAssemblymode());
            }

            Map<String, List<MultiFactoryControlVO>> viewMultiFactoryControlMap = importBasicListDTO.getViewMultiFactoryControlMap();
            if (CollUtil.isNotEmpty(viewMultiFactoryControlMap) && CollUtil.isNotEmpty((Collection)viewMultiFactoryControlMap.get(partXmlNodeDTO.getView()))) {
                List<MultiFactoryControlVO> controlVOList = (List)viewMultiFactoryControlMap.get(partXmlNodeDTO.getView());
                if (CollUtil.isNotEmpty(controlVOList)) {
                    MultiFactoryControlVO multiFactoryControlVO = (MultiFactoryControlVO)controlVOList.get(0);
                    if (Boolean.TRUE.equals(multiFactoryControlVO.getShowBomPurpose())) {
                        partDO.setVariation1((String)StringUtils.defaultIfBlank(partXmlNodeDTO.getVariation1(), (CharSequence)null));
                    }

                    if (Boolean.TRUE.equals(multiFactoryControlVO.getShowSpareBom())) {
                        partDO.setVariation2((String)StringUtils.defaultIfBlank(partXmlNodeDTO.getVariation2(), (CharSequence)null));
                    }
                }
            }

            this.typlmPartBomImportUtil.setPartLifeCycleTemplateAttr(partDO, partXmlNodeDTO, importBasicListDTO);
            partDO.setBranchid(this.snowflakeIdComponent.getInstance().nextId());
            partDO.setDescription(partXmlNodeDTO.getRemark());
            this.resetPartInfo(partXmlNodeDTO, masterDo, partDO);
            masterDo.setContaineroid(partDO.getContaineroid());
            masterDo.setContainerotype(partDO.getContainerotype());
            masterDo.setDefaultiteratedoid(partDO.getOid());
            masterDo.setDefaultiteratedotype(partDO.getOtype());
            this.setPartClassificationInfo(partImportToDBDTO, partXmlNodeDTO.getClassificationOid(), partDO);
            partImportToDBDTO.getPartMasterDOInsertList().add(masterDo);
            partImportToDBDTO.getPartDOInsertList().add(partDO);
            partImportToDBDTO.getNewControlBranchPartDOList().add(partDO);
            partImportToDBDTO.getPartFolderMemberLink().add(partDO);
            allNewMasterNumberMap.put(partXmlNodeDTO.getPartnumber(), partDO);
            allNewMasterNumberMasterMap.put(partXmlNodeDTO.getPartnumber(), masterDo);
            partImportToDBDTO.getSaveAsPartMap().put(partXmlNodeDTO.getSourcePartOid(), partDO);
            partImportToDBDTO.getDownStreamPartMap().put(partXmlNodeDTO.getSourcePartOid(), partDO);
            PartImportIbaBeanDTO partImportIbaBeanDTO = this.typlmPartBomImportUtil.setEntityIbaInfo(importBasicListDTO, partDO, partXmlNodeDTO.getAttributes());
            if (Objects.nonNull(partImportIbaBeanDTO)) {
                partImportToDBDTO.getIbaBeanDTOInsertList().add(partImportIbaBeanDTO);
            }

            this.createCadBuildRuleDTO(importBasicListDTO, partImportToDBDTO, partDO, partXmlNodeDTO.getId(), partXmlNodeDTO.getPartnumber());
            this.typlmPartBomImportUtil.writeLogVo(partXmlNodeDTO.getPartnumber(), "Part created successfully!", PartBomErrorCodeEnum.BOM_IMPORT_PART_CREATED_SUCCESSFULLY.getLocaleMessage(new Object[]{partXmlNodeDTO.getPartnumber()}), "NORMAL", returnLogMap);
        }

        importBasicListDTO.setAllNewMasterNumberPartMap(allNewMasterNumberMap);
        importBasicListDTO.setAllNewMasterNumberMasterMap(allNewMasterNumberMasterMap);
        TyplmLoggerUtil.debug(log, () -> {
            return "newPartMaster ==> end newPartMaster";
        });
        return partImportToDBDTO;
    }

    private boolean createCadBuildRuleDTO(TyPartImportBasicListDTO importBasicListDTO, PartImportToDBDTO partImportToDBDTO, PartDO partDO, String xmlPartid, String partnumber) {
        boolean isCreateBuildRule = true;
        if (!"true".equalsIgnoreCase(importBasicListDTO.getIsCadImport())) {
            return isCreateBuildRule;
        } else {
            Map<String, MDAImportOutDocVo> cadXmlIdMap = importBasicListDTO.getCadXmlIdMap();
            List<ImportStructDTO> docPartStruct = importBasicListDTO.getDocPartStruct();
            List<ImportStructDTO> filterStructs = (List)docPartStruct.stream().filter((structx) -> {
                return xmlPartid.equalsIgnoreCase(structx.getParentId());
            }).collect(Collectors.toList());
            if (CollectionUtils.isEmpty(filterStructs)) {
                return false;
            } else {
                Iterator var10 = filterStructs.iterator();

                while(var10.hasNext()) {
                    ImportStructDTO struct = (ImportStructDTO)var10.next();
                    MDAImportOutDocVo docVo = (MDAImportOutDocVo)cadXmlIdMap.get(struct.getChildId());
                    if (!Objects.isNull(docVo) && !Objects.isNull(partDO) && !this.typlmImportThreeDimService.checkTypeIsDrw(docVo.getDocPostfixType())) {
                        List<CADBuildRuleDO> cadBuildRuleDOS = this.typlmCadRuleBuildService.queryByABBranchId(docVo.getBranchid(), partDO.getBranchid());
                        BigInteger buildRuleId = null;
                        Long buildType;
                        if (CollectionUtils.isEmpty(cadBuildRuleDOS)) {
                            CadBuildRuleDTO cadBuildRuleDTO = this.buildCadbuildRule(importBasicListDTO, partImportToDBDTO, partDO, partnumber, docVo);
                            buildType = CadPartLinkEnum.getLinkTypeLongByEnName(cadBuildRuleDTO.getBuildtype());
                        } else {
                            CADBuildRuleDO cadBuildRuleDO = (CADBuildRuleDO)cadBuildRuleDOS.get(0);
                            buildRuleId = cadBuildRuleDO.getOid();
                            buildType = Long.parseLong(String.valueOf(cadBuildRuleDO.getBuildtype()));
                            isCreateBuildRule = false;
                        }

                        this.buildCadBuildHistory(partImportToDBDTO, partDO.getOid(), CommonUtil.stringToBigInteger(docVo.getDocId()), buildRuleId, buildType);
                    }
                }

                return isCreateBuildRule;
            }
        }
    }

    private void buildCadBuildHistory(PartImportToDBDTO partImportToDBDTO, BigInteger partId, BigInteger cadId, BigInteger buildRuleId, Long buildType) {
        if (!Objects.isNull(partId) && !Objects.isNull(cadId) && !BigInteger.ZERO.equals(partId) && !BigInteger.ZERO.equals(cadId)) {
            PartImportBuildHistoryDTO cadBuildHistoryDTO = new PartImportBuildHistoryDTO();
            cadBuildHistoryDTO.setBuildRuleId(buildRuleId);
            cadBuildHistoryDTO.setBuildtype(buildType);
            cadBuildHistoryDTO.setCadId(cadId);
            cadBuildHistoryDTO.setPartId(partId);
            partImportToDBDTO.getCadBuildHistoryDTOList().add(cadBuildHistoryDTO);
        }
    }

    private CadBuildRuleDTO buildCadbuildRule(TyPartImportBasicListDTO importBasicListDTO, PartImportToDBDTO partImportToDBDTO, PartDO partDO, String partnumber, MDAImportOutDocVo docVo) {
        CadBuildRuleDTO cadBuildRuleDTO = new CadBuildRuleDTO();
        cadBuildRuleDTO.setAoid(new BigInteger(docVo.getDocId()));
        cadBuildRuleDTO.setAotype("ty.inteplm.cad.CTyCADDoc");
        cadBuildRuleDTO.setABranchId(docVo.getBranchid());
        cadBuildRuleDTO.setBoid(partDO.getOid());
        cadBuildRuleDTO.setBotype("ty.inteplm.part.CTyPart");
        cadBuildRuleDTO.setBBranchId(partDO.getBranchid());
        cadBuildRuleDTO.setBuildtype(importBasicListDTO.getPartLinkType());
        partImportToDBDTO.getCadBuildRuleDTOList().add(cadBuildRuleDTO);
        importBasicListDTO.getDocBranchidCodeMap().put(docVo.getBranchid(), docVo.getCode());
        importBasicListDTO.getPartBranchidCodeMap().put(partDO.getBranchid(), partnumber);
        return cadBuildRuleDTO;
    }

    private void resetPartInfo(PartXmlNodeDTO partXmlNodeDTO, PartMasterDO masterDO, PartDO partDO) {
        Date date;
        if (StringUtils.isNotEmpty(partXmlNodeDTO.getCreatestamp())) {
            date = ZTDateUtils.dateStrToDate(partXmlNodeDTO.getCreatestamp(), "yyyy-MM-dd HH:mm:ss");
            masterDO.setCreatestamp(date);
            partDO.setCreatestamp(date);
        }

        if (StringUtils.isNotEmpty(partXmlNodeDTO.getCreatoroid())) {
            partDO.setCreatoroid(new BigInteger(partXmlNodeDTO.getCreatoroid()));
            partDO.setOwneroid(new BigInteger(partXmlNodeDTO.getCreatoroid()));
        }

        if (StringUtils.isNotEmpty(partXmlNodeDTO.getOwneroid())) {
            partDO.setOwneroid(new BigInteger(partXmlNodeDTO.getOwneroid()));
        }

        if (StringUtils.isNotEmpty(partXmlNodeDTO.getModifystamp())) {
            date = ZTDateUtils.dateStrToDate(partXmlNodeDTO.getCreatestamp(), "yyyy-MM-dd HH:mm:ss");
            partDO.setModifystamp(date);
            partDO.setUpdatestamp(date);
        }

        if (StringUtils.isNotEmpty(partXmlNodeDTO.getUpdatoroid())) {
            partDO.setUpdatoroid(new BigInteger(partXmlNodeDTO.getUpdatoroid()));
        }

    }

    private void setPartClassificationInfo(PartImportToDBDTO partImportToDBDTO, String classificationOid, PartDO partDO) {
        if (StringUtils.isNotEmpty(classificationOid)) {
            InsertClassificationType insertClassificationType = new InsertClassificationType();
            insertClassificationType.setObjId(partDO.getMasteredoid());
            insertClassificationType.setObjType(partDO.getMasteredotype());
            insertClassificationType.setClassificationId(new BigInteger(classificationOid));
            insertClassificationType.setClassificationType("ty.inteplm.type.CTyClassification");
            partImportToDBDTO.getClassificationList().add(insertClassificationType);
        }

    }

    private void checkPartDocBuildLink(TyPartImportBasicListDTO importBasicListDTO, List<CadBuildRuleDTO> cadBuildRuleDTOList, List<Map<ResponseCodeEnum, String[]>> exceptions) {
        if (!CollectionUtils.isEmpty(cadBuildRuleDTOList)) {
            List<BigInteger> partBranchidList = new ArrayList();
            List<BigInteger> docBranchidList = new ArrayList();
            cadBuildRuleDTOList.forEach((dto) -> {
                docBranchidList.add(dto.getABranchId());
                partBranchidList.add(dto.getBBranchId());
            });
            List<TyBuildObjVO> tyBuildObjVOS = this.typlmPartQueryExtService.queryBuildObjByBranchid(partBranchidList, docBranchidList);
            this.checkBuildObj(importBasicListDTO, cadBuildRuleDTOList, exceptions, tyBuildObjVOS);
        }
    }

    private void checkBuildObj(TyPartImportBasicListDTO importBasicListDTO, List<CadBuildRuleDTO> cadBuildRuleDTOList, List<Map<ResponseCodeEnum, String[]>> exceptions, List<TyBuildObjVO> tyBuildObjVOS) {
        if (!CollectionUtils.isEmpty(tyBuildObjVOS)) {
            cadBuildRuleDTOList.forEach((dto) -> {
                BigInteger docBranchid = dto.getABranchId();
                String docnumber = (String)importBasicListDTO.getDocBranchidCodeMap().get(docBranchid);
                BigInteger partBranchid = dto.getBBranchId();
                String partnumber = (String)importBasicListDTO.getPartBranchidCodeMap().get(partBranchid);
                List<String> partnumberList = new ArrayList();
                tyBuildObjVOS.forEach((buildObjVO) -> {
                    if (String.valueOf(docBranchid).equalsIgnoreCase(buildObjVO.getObjbranchid()) && "caddoc".equalsIgnoreCase(buildObjVO.getObjtype()) && !partnumber.equalsIgnoreCase(buildObjVO.getBuildobjnumber())) {
                        partnumberList.add(buildObjVO.getBuildobjnumber());
                    }

                });
                if (!CollectionUtils.isEmpty(partnumberList)) {
                    TyplmExceptionUtil.addExceptions(ResponseCodeEnum.BIZ_CAD_BUILDRULE_ALREADY_EXISTS, new String[]{docnumber, partnumberList.toString(), partnumber}, exceptions);
                }

                List<String> docnumberList = new ArrayList();
                tyBuildObjVOS.forEach((buildObjVO) -> {
                    if (String.valueOf(partBranchid).equalsIgnoreCase(buildObjVO.getObjbranchid()) && "part".equalsIgnoreCase(buildObjVO.getObjtype()) && !docnumber.equalsIgnoreCase(buildObjVO.getBuildobjnumber())) {
                        docnumberList.add(buildObjVO.getBuildobjnumber());
                    }

                });
                if (!CollectionUtils.isEmpty(docnumberList)) {
                    TyplmExceptionUtil.addExceptions(ResponseCodeEnum.BIZ_PART_BUILDRULE_ALREADY_EXISTS, new String[]{partnumber, docnumberList.toString(), docnumber}, exceptions);
                }

            });
        }
    }

    private void setNewPartAttr(String partnumber, PartDO partDO, PartMasterDO masterDo, CTyEntityBaseDO foldeEntityBase, PartXmlNodeDTO partXmlNodeDTO, TyPartImportBasicListDTO importBasicListDTO, Object policyConfig, Map<String, Map<String, String>> typeAndNumberMap) {
        this.typlmPartBomImportUtil.setPartFolder(partDO, foldeEntityBase);
        this.typlmPartBomImportUtil.setPartVersion(partnumber, masterDo, partDO, partXmlNodeDTO.getParttypedefname(), importBasicListDTO, policyConfig, typeAndNumberMap);
        if (!"saveAs".equalsIgnoreCase(importBasicListDTO.getIsCadImport())) {
            this.typlmPartBomImportUtil.setPartEnumAttr(partDO, partXmlNodeDTO, importBasicListDTO, false);
        } else {
            partDO.setSourcekey(partXmlNodeDTO.getSource());
            partDO.setSecuritylabels(partXmlNodeDTO.getSecurity());
            partDO.setParttypekey(partXmlNodeDTO.getAssemblymode());
        }

        Map<String, List<MultiFactoryControlVO>> viewMultiFactoryControlMap = importBasicListDTO.getViewMultiFactoryControlMap();
        if (CollUtil.isNotEmpty(viewMultiFactoryControlMap) && CollUtil.isNotEmpty((Collection)viewMultiFactoryControlMap.get(partXmlNodeDTO.getView()))) {
            List<MultiFactoryControlVO> controlVOList = (List)viewMultiFactoryControlMap.get(partXmlNodeDTO.getView());
            if (CollUtil.isNotEmpty(controlVOList)) {
                MultiFactoryControlVO multiFactoryControlVO = (MultiFactoryControlVO)controlVOList.get(0);
                if (Boolean.TRUE.equals(multiFactoryControlVO.getShowBomPurpose())) {
                    partDO.setVariation1((String)StringUtils.defaultIfBlank(partXmlNodeDTO.getVariation1(), (CharSequence)null));
                }

                if (Boolean.TRUE.equals(multiFactoryControlVO.getShowSpareBom())) {
                    partDO.setVariation2((String)StringUtils.defaultIfBlank(partXmlNodeDTO.getVariation2(), (CharSequence)null));
                }
            }
        }

        this.typlmPartBomImportUtil.setPartLifeCycleTemplateAttr(partDO, partXmlNodeDTO, importBasicListDTO);
        partDO.setBranchid(this.snowflakeIdComponent.getInstance().nextId());
        partDO.setDescription(partXmlNodeDTO.getRemark());
    }

    private void newPartViewVersion(TyPartImportBasicListDTO importBasicListDTO, UserDO userDO, PartImportToDBDTO partImportToDBDTO, Map<String, List<PartImportLogVO>> returnLogMap) {
        log.info("=====>>>> batchImportPartBom:begin newPartViewVersion");
        Map<String, BigInteger> allNewPartViewNumberOidMap = importBasicListDTO.getAllNewPartViewNumberOidMap();
        Map<String, PartDO> allNewPartViewNumberPartMap = importBasicListDTO.getAllNewPartViewNumberPartMap();
        log.info("=====>>>> batchImportPartBom:newPartViewVersion=====>>>>allNewPartViewNumberOidMap:" + allNewPartViewNumberOidMap);
        Map<String, Object> preferenceBykeys = this.tyPreferenceValueService.getPreferenceValueMap(Arrays.asList("ManuallySetChangePolicy"));
        Object policyConfig = preferenceBykeys.get("ManuallySetChangePolicy");
        Map<BigInteger, PartMasterDO> masterMap = new HashMap();
        Iterator var10 = importBasicListDTO.getAllMasterDOMap().values().iterator();

        while(var10.hasNext()) {
            PartMasterDO masterDO = (PartMasterDO)var10.next();
            masterMap.put(masterDO.getOid(), masterDO);
        }

        Map<String, Map<String, String>> typeAndNumberMap = new HashMap();
        Map<String, String> numberMap = new HashMap();
        Iterator var12 = importBasicListDTO.getAllPartTypeRelDTOMap().entrySet().iterator();

        Map.Entry entry;
        while(var12.hasNext()) {
            entry = (Map.Entry)var12.next();
            Iterator var14 = ((List)entry.getValue()).iterator();

            while(var14.hasNext()) {
                PartTypeRelDTO partTypeRelDTO = (PartTypeRelDTO)var14.next();
                numberMap.put(partTypeRelDTO.getPartNumber(), partTypeRelDTO.getUserSetVersion());
            }

            typeAndNumberMap.put((String) entry.getKey(), numberMap);
        }

        var12 = allNewPartViewNumberOidMap.entrySet().iterator();

        while(var12.hasNext()) {
            entry = (Map.Entry)var12.next();
            String partnumber = (String)entry.getKey();
            PartMasterDO masterDo = (PartMasterDO)masterMap.get(entry.getValue());
            if (!Objects.isNull(masterDo)) {
                PartXmlNodeDTO partXmlNodeDTO = (PartXmlNodeDTO)importBasicListDTO.getPartNumberMap().get(partnumber);
                ViewDefDO viewDefDO = (ViewDefDO)importBasicListDTO.getAllViewDefDOMap().get(partXmlNodeDTO.getView());
                CTyEntityBaseDO foldeEntityBase = this.typlmPartBomImportCheckUtil.getFoldeEntityBase(partnumber, importBasicListDTO);
                PartDO newPartDO = new PartDO();
                this.typlmPartBomImportUtil.setPartAttr(newPartDO, masterDo, userDO.getOid(), viewDefDO);
                this.setNewPartAttr(partnumber, newPartDO, masterDo, foldeEntityBase, partXmlNodeDTO, importBasicListDTO, policyConfig, typeAndNumberMap);
                partImportToDBDTO.getNewControlBranchPartDOList().add(newPartDO);
                partImportToDBDTO.getPartDOInsertList().add(newPartDO);
                partImportToDBDTO.getPartFolderMemberLink().add(newPartDO);
                allNewPartViewNumberPartMap.put(partnumber, newPartDO);
                partImportToDBDTO.getDownStreamPartMap().put(partXmlNodeDTO.getSourcePartOid(), newPartDO);
                PartImportIbaBeanDTO partImportIbaBeanDTO = this.typlmPartBomImportUtil.setEntityIbaInfo(importBasicListDTO, newPartDO, partXmlNodeDTO.getAttributes());
                if (Objects.nonNull(partImportIbaBeanDTO)) {
                    partImportToDBDTO.getIbaBeanDTOInsertList().add(partImportIbaBeanDTO);
                }

                this.createCadBuildRuleDTO(importBasicListDTO, partImportToDBDTO, newPartDO, partXmlNodeDTO.getId(), partXmlNodeDTO.getPartnumber());
                this.typlmPartBomImportUtil.writeLogVo(partXmlNodeDTO.getPartnumber(), "New view version succeeded!", PartBomErrorCodeEnum.BOM_IMPORT_VIEW_PART_CREATED_SUCCESSFULLY.getLocaleMessage(new Object[]{partXmlNodeDTO.getPartnumber(), viewDefDO.getName()}), "NORMAL", returnLogMap);
            }
        }

        log.info("=====>>>> batchImportPartBom:end newPartViewVersion");
    }

    private void updateWrkPart(TyPartImportBasicListDTO importBasicListDTO, PartImportToDBDTO partImportToDBDTO, PartXmlGlobeNodeDTO globeNodeDTO, Map<String, List<PartImportLogVO>> returnLogMap) {
        log.info("=====>>>> batchImportPartBom:begin updateWrkPart");
        Map<String, PartDO> allWrkPartDOMap = importBasicListDTO.getAllWrkPartDOMap();
        List<PartDO> allCheckinPart = new ArrayList();
        boolean isupdatePartAttr = true;
        if ("true".equalsIgnoreCase(importBasicListDTO.getIsCadImport())) {
            isupdatePartAttr = importBasicListDTO.isUpdatePart();
        }

        if ("false".equalsIgnoreCase(importBasicListDTO.getIsCadImport())) {
            isupdatePartAttr = importBasicListDTO.isUpdatePart();
            if (!isupdatePartAttr) {
                return;
            }
        }

        log.info("=====>>>> batchImportPartBom:updateWrkPart=====>>>>allWrkPartDOMap:" + allWrkPartDOMap);
        Iterator var8 = allWrkPartDOMap.entrySet().iterator();

        while(var8.hasNext()) {
            Map.Entry<String, PartDO> partDOEntry = (Map.Entry)var8.next();
            PartXmlNodeDTO partXmlNodeDTO = (PartXmlNodeDTO)importBasicListDTO.getPartNumberMap().get(partDOEntry.getKey());
            if ("ref".equalsIgnoreCase(partXmlNodeDTO.getOptype())) {
                this.typlmPartBomImportUtil.writeLogVo(partXmlNodeDTO.getPartnumber(), "忽略更新零件", PartBomErrorCodeEnum.BOM_IMPORT_PART_IS_BORROWED_IGNORING_UPDATE.getLocaleMessage(new Object[]{partXmlNodeDTO.getPartnumber()}), "ERROR", returnLogMap);
            } else {
                PartDO wrkDO = (PartDO)partDOEntry.getValue();
                PartImportLogVO partImportLogVO = new PartImportLogVO();
                partImportLogVO.setPartNumber(wrkDO.getPartnumber());
                partImportLogVO.setLogTitle("Parts upgraded successfully!");
                partImportLogVO.setLogDetail(PartBomErrorCodeEnum.BOM_IMPORT_PART_UPGRADED_SUCCESSFULLY.getLocaleMessage(new Object[]{wrkDO.getPartnumber()}));
                partImportLogVO.setLogFlag("NORMAL");
                if (globeNodeDTO.getAutocheckin().equalsIgnoreCase("N")) {
                    allCheckinPart.add(wrkDO);
                    partImportLogVO.setEvent("check_in");
                    partImportLogVO.setPartOid(wrkDO.getOid().toString());
                }

                if (!isupdatePartAttr) {
                    this.createCadBuildRuleDTO(importBasicListDTO, partImportToDBDTO, wrkDO, partXmlNodeDTO.getId(), partXmlNodeDTO.getPartnumber());
                } else {
                    wrkDO.setDescription(partXmlNodeDTO.getRemark());
                    this.typlmPartBomImportUtil.setPartEnumAttr(wrkDO, partXmlNodeDTO, importBasicListDTO, true);
                    partImportToDBDTO.getPartDOUpdateList().add(wrkDO);
                    partImportToDBDTO.getPartDOUpdateWrkList().add(wrkDO);
                    PartImportIbaBeanDTO partImportIbaBeanDTO = this.typlmPartBomImportUtil.setEntityIbaInfo(importBasicListDTO, wrkDO, partXmlNodeDTO.getAttributes());
                    if (Objects.nonNull(partImportIbaBeanDTO)) {
                        partImportToDBDTO.getIbaBeanDTOUpdateList().add(partImportIbaBeanDTO);
                    }

                    this.createCadBuildRuleDTO(importBasicListDTO, partImportToDBDTO, wrkDO, partXmlNodeDTO.getId(), partXmlNodeDTO.getPartnumber());
                    this.typlmPartBomImportUtil.writeLogVo(partImportLogVO, returnLogMap);
                }
            }
        }

        partImportToDBDTO.setAllCheckinPart(allCheckinPart);
        log.info("=====>>>> batchImportPartBom:end updateWrkPart");
    }

    private PartImportToDBDTO buildPartAndBom(UserDO userDO, PartXmlAllNodeDTO partXmlAllNodeDTO, Map<String, List<PartImportLogVO>> returnLogMap, TyPartImportBasicListDTO importBasicListDTO) {
        TimeInterval timeInterval = new TimeInterval();
        timeInterval.start("begin");
        timeInterval.start();
        PartImportToDBDTO partImportToDBDTO = this.newPartMaster(importBasicListDTO, userDO, returnLogMap);
        log.info("=====>>>> buildPartAndBom: newPartMaster:{}", timeInterval.interval());
        timeInterval.restart();
        partImportToDBDTO.setWorkSpace(partXmlAllNodeDTO.getWorkSpace());
        this.newPartViewVersion(importBasicListDTO, userDO, partImportToDBDTO, returnLogMap);
        log.info("=====>>>> buildPartAndBom: newPartViewVersion:{}", timeInterval.interval());
        timeInterval.restart();
        this.upgradePart(partXmlAllNodeDTO, importBasicListDTO, partImportToDBDTO, userDO, returnLogMap);
        log.info("=====>>>> buildPartAndBom: upgradePart:{}", timeInterval.interval());
        timeInterval.restart();
        this.updateWrkPart(importBasicListDTO, partImportToDBDTO, partXmlAllNodeDTO.getGlobe(), returnLogMap);
        log.info("=====>>>> buildPartAndBom: updateWrkPart:{}", timeInterval.interval());
        timeInterval.restart();
        if (!CollectionUtils.isEmpty(partXmlAllNodeDTO.getPartStruct())) {
            if (!importBasicListDTO.isUpdateBom()) {
                boolean isCadImport = "true".equalsIgnoreCase(importBasicListDTO.getIsCadImport());
                boolean isNotCadImport = "false".equalsIgnoreCase(importBasicListDTO.getIsCadImport());
                if (isCadImport || isNotCadImport) {
                    return partImportToDBDTO;
                }
            }

            this.collectPartUsageLink(partXmlAllNodeDTO, importBasicListDTO, partImportToDBDTO, returnLogMap);
            log.info("=====>>>> buildPartAndBom: collectPartUsageLink:{}", timeInterval.interval());
            timeInterval.restart();
        }

        this.collectionExistCadPartBuildRule(importBasicListDTO, partImportToDBDTO);
        log.info("=====>>>> buildPartAndBom: collectionExistCadPartBuildRule:{}", timeInterval.interval());
        log.info("=====>>>> batchImportPartBom: end buildPartAndBom:{}", timeInterval.interval("begin"));
        return partImportToDBDTO;
    }

    private void collectionExistCadPartBuildRule(TyPartImportBasicListDTO importBasicListDTO, PartImportToDBDTO partImportToDBDTO) {
        Map<String, PartXmlNodeDTO> partNumberMap = importBasicListDTO.getPartNumberMap();
        Map<String, PartDO> noModifyRightPartDOMap = importBasicListDTO.getNoModifyRightPartDOMap();
        Map<String, MDAImportOutDocVo> cadXmlIdMap = importBasicListDTO.getCadXmlIdMap();
        List<ImportStructDTO> docPartStruct = importBasicListDTO.getDocPartStruct();
        if (CollUtil.isNotEmpty(docPartStruct) && CollUtil.isNotEmpty(partNumberMap) && CollUtil.isNotEmpty(cadXmlIdMap)) {
            Map<String, String> xmlPartIdNumberMap = (Map)Lists.newArrayList(partNumberMap.values()).stream().collect(Collectors.toMap(PartXmlNodeDTO::getId, PartXmlNodeDTO::getPartnumber, (k1, k2) -> {
                return k1;
            }));
            Iterator var8 = docPartStruct.iterator();

            while(var8.hasNext()) {
                ImportStructDTO importStructDTO = (ImportStructDTO)var8.next();
                String xmlCadId = importStructDTO.getParentId();
                String xmlPartId = importStructDTO.getChildId();
                MDAImportOutDocVo cadVo = (MDAImportOutDocVo)cadXmlIdMap.get(xmlCadId);
                String partNumber = (String)xmlPartIdNumberMap.get(xmlPartId);
                PartDO partDO = (PartDO)noModifyRightPartDOMap.get(partNumber);
                if (Objects.nonNull(cadVo) && Objects.nonNull(partDO)) {
                    CadBuildRuleDTO buildRuleDTO = new CadBuildRuleDTO();
                    buildRuleDTO.setABranchId(cadVo.getBranchid());
                    buildRuleDTO.setAoid(new BigInteger(cadVo.getDocId()));
                    buildRuleDTO.setBBranchId(partDO.getBranchid());
                    buildRuleDTO.setBoid(partDO.getOid());
                    partImportToDBDTO.getNoRightBuildRuleDTOList().add(buildRuleDTO);
                }
            }
        }

    }

    private PartDO getParentPart(PartXmlNodeDTO partentPartXmlNode, PartXmlNodeDTO childPartXmlNode, PartXmlStructNodeDTO struct, TyPartImportBasicListDTO basicListDTO, Map<String, List<PartImportLogVO>> returnLogMap) {
        if (Objects.isNull(childPartXmlNode)) {
            this.typlmPartBomImportUtil.writeLogVo(struct.getChildId(), "id在partlist中不存在", "id在partlist中不存在", "ERROR", returnLogMap);
            return partDONull;
        } else if (Objects.isNull(partentPartXmlNode)) {
            this.typlmPartBomImportUtil.writeLogVo(struct.getChildId(), "id在partlist中不存在", "id在partlist中不存在", "ERROR", returnLogMap);
            return partDONull;
        } else if ("ref".equalsIgnoreCase(partentPartXmlNode.getOptype())) {
            String title = "忽略更新结构";
            String pcnumber = "结构[父件" + partentPartXmlNode.getPartnumber() + "-" + "子件" + childPartXmlNode.getPartnumber() + "]";
            String detail = PartBomErrorCodeEnum.BOM_IMPORT_PARENT_IS_BORROWED_IGNORING_UPDATE.getLocaleMessage(new Object[]{pcnumber, partentPartXmlNode.getPartnumber()});
            this.typlmPartBomImportUtil.writeLogVo(pcnumber, title, detail, "ERROR", returnLogMap);
            return partDONull;
        } else {
            Map<String, PartMasterDO> masterDOMap = new HashMap();
            PartDO parentPartDO = this.getPart(partentPartXmlNode.getPartnumber(), basicListDTO, masterDOMap);
            if (Objects.isNull(parentPartDO)) {
                this.typlmPartBomImportUtil.writeLogVo(struct.getParentId(), "id在partlist中不存在", "id在partlist中不存在", "ERROR", returnLogMap);
                return partDONull;
            } else if (!this.checkParentPartRight(partentPartXmlNode.getPartnumber(), childPartXmlNode.getPartnumber(), basicListDTO, returnLogMap)) {
                return partDONull;
            } else if (Boolean.TRUE.equals(this.notChildPartReadPermissionsIsCreateBom)) {
                return parentPartDO;
            } else {
                List<String> noReadRightPartList = basicListDTO.getNoReadRightPartList();
                if (noReadRightPartList.contains(childPartXmlNode.getPartnumber())) {
                    Map<String, Object> noPartReadRightStop = this.typlmPreferenceValueUtil.readPreferenceValueByKeywords(Collections.singletonList("BatchImport_NoReadRightStop"));
                    boolean noPartReadRightPart = BooleanUtils.toBooleanDefaultIfNull((Boolean)noPartReadRightStop.get("BatchImport_NoReadRightStop"), Boolean.TRUE);
                    if (!noPartReadRightPart) {
                        String title = "忽略更新结构";
                        String pcnumber = "结构[父件" + partentPartXmlNode.getPartnumber() + "-" + "子件" + childPartXmlNode.getPartnumber() + "]";
                        String detail = PartBomErrorCodeEnum.BOM_IMPORT_NOT_HAVE_CHILD_READ_PERMISSIONS_IGNORING_UPDATE.getLocaleMessage(new Object[]{pcnumber, childPartXmlNode.getPartnumber()});
                        this.typlmPartBomImportUtil.writeLogVo(pcnumber, title, detail, "ERROR", returnLogMap);
                        return partDONull;
                    }
                }

                return parentPartDO;
            }
        }
    }

    private boolean checkParentPartRight(String parentNumber, String childNumber, TyPartImportBasicListDTO basicListDTO, Map<String, List<PartImportLogVO>> returnLogMap) {
        boolean flag = true;
        String pcnumber = "结构[父件" + parentNumber + "-" + "子件" + childNumber + "]";
        String title;
        String detail;
        if (basicListDTO.getNoModifyRightPartList().contains(parentNumber)) {
            flag = false;
            title = "忽略更新结构";
            detail = PartBomErrorCodeEnum.BOM_IMPORT_NOT_HAVE_PARENT_MODIFY_PERMISSIONS.getLocaleMessage(new Object[]{pcnumber, parentNumber});
            this.typlmPartBomImportUtil.writeLogVo(pcnumber, title, detail, "ERROR", returnLogMap);
        }

        if (basicListDTO.getCoPartList().contains(parentNumber)) {
            flag = false;
            title = "忽略更新结构";
            detail = PartBomErrorCodeEnum.BOM_IMPORT_SKIPPING_UPDATING_STRUCTURE.getLocaleMessage(new Object[]{pcnumber, parentNumber});
            this.typlmPartBomImportUtil.writeLogVo(pcnumber, title, detail, "ERROR", returnLogMap);
        }

        return flag;
    }

    private PartMasterDO getChildPartMaster(String partNumber, TyPartImportBasicListDTO basicListDTO, Map<String, List<PartImportLogVO>> returnLogMap) {
        if (StringUtils.isEmpty(partNumber)) {
            return partMasterDONull;
        } else {
            Map<String, PartMasterDO> childMasterDOMap = new HashMap();
            PartDO childPartDO = this.getPart(partNumber, basicListDTO, childMasterDOMap);
            if (Objects.isNull(childPartDO)) {
                this.typlmPartBomImportUtil.writeLogVo(partNumber, "数据异常", "数据异常", "ERROR", returnLogMap);
                return partMasterDONull;
            } else {
                PartMasterDO childPartMasterDO = (PartMasterDO)childMasterDOMap.get(partNumber);
                if (Objects.isNull(childPartMasterDO)) {
                    this.typlmPartBomImportUtil.writeLogVo(partNumber, "数据异常", "数据异常", "ERROR", returnLogMap);
                    return partMasterDONull;
                } else {
                    return childPartMasterDO;
                }
            }
        }
    }

    private PartDO getPart(String partnumber, TyPartImportBasicListDTO basicListDTO, Map<String, PartMasterDO> masterDOMap) {
        PartDO partDO = null;
        PartMasterDO partMasterDO = null;
        if (basicListDTO.getAllNewMasterNumberMasterMap().containsKey(partnumber)) {
            partDO = (PartDO)basicListDTO.getAllNewMasterNumberPartMap().get(partnumber);
            partMasterDO = (PartMasterDO)basicListDTO.getAllNewMasterNumberMasterMap().get(partnumber);
        } else if (basicListDTO.getAllNewPartViewNumberPartMap().containsKey(partnumber)) {
            partDO = (PartDO)basicListDTO.getAllNewPartViewNumberPartMap().get(partnumber);
            partMasterDO = (PartMasterDO)basicListDTO.getAllMasterDOMap().get(partnumber);
        } else if (basicListDTO.getAllWrkPartDOMap().containsKey(partnumber)) {
            partDO = (PartDO)basicListDTO.getAllWrkPartDOMap().get(partnumber);
            partMasterDO = (PartMasterDO)basicListDTO.getAllMasterDOMap().get(partnumber);
        } else if (basicListDTO.getAllAfterUpgradePartDOMap().containsKey(partnumber)) {
            partDO = (PartDO)basicListDTO.getAllAfterUpgradePartDOMap().get(partnumber);
            partMasterDO = (PartMasterDO)basicListDTO.getAllMasterDOMap().get(partnumber);
        } else {
            partMasterDO = (PartMasterDO)basicListDTO.getAllMasterDOMap().get(partnumber);
            if (basicListDTO.getAllUpdatePartDOMap().containsKey(partMasterDO.getOid())) {
                partDO = (PartDO)basicListDTO.getAllUpdatePartDOMap().get(partMasterDO.getOid());
            }
        }

        masterDOMap.put(partnumber, partMasterDO);
        return partDO;
    }

    private PartDO copySourcePart(PartDO sourcePartDO, UserDO userDO) {
        PartDO targetPartDO = new PartDO();
        this.typlmPartBomImportUtil.copyPart(sourcePartDO, targetPartDO, userDO);
        return targetPartDO;
    }

    private void collectPartUsageLink(PartXmlAllNodeDTO partXmlAllNodeDTO, TyPartImportBasicListDTO basicListDTO, PartImportToDBDTO partImportToDBDTO, Map<String, List<PartImportLogVO>> returnLogMap) {
        TyplmLoggerUtil.debug(log, () -> {
            return "collectPartUsageLink ==> begin collectPartUsageLink";
        });
        List<PartXmlStructNodeDTO> partStruct = partXmlAllNodeDTO.getPartStruct();
        List<PartUsageLinkDO> partUsageLinkDOList = new ArrayList();
        if (this.notUpgradeVersion && CollUtil.isNotEmpty(basicListDTO.getAllUpdatePartDOMap())) {
            Collection<PartDO> values = basicListDTO.getAllUpdatePartDOMap().values();
            List<String> partids = new ArrayList();
            values.forEach((part) -> {
                partids.add(String.valueOf(part.getOid()));
            });
            partUsageLinkDOList = this.typlmPartUsageLinkService.queryPartUsageLinkByAoids(partids);
        }

        List<PartXmlNodeDTO> partList = partXmlAllNodeDTO.getPartList();
        Map<String, PartXmlNodeDTO> partMap = (Map)partList.stream().collect(Collectors.toMap(PartXmlNodeDTO::getId, (nodeDTO) -> {
            return nodeDTO;
        }));
        List<BigInteger> needDeleteParentOids = new ArrayList();
        Map<BigInteger, List<Long>> lineNumberMap = new HashMap();
        Iterator var11 = partStruct.iterator();

        while(var11.hasNext()) {
            PartXmlStructNodeDTO struct = (PartXmlStructNodeDTO)var11.next();
            PartXmlNodeDTO partentPartXmlNode = (PartXmlNodeDTO)partMap.get(struct.getParentId());
            PartXmlNodeDTO childPartXmlNode = (PartXmlNodeDTO)partMap.get(struct.getChildId());
            boolean flag = Objects.nonNull(childPartXmlNode) && Objects.nonNull(partentPartXmlNode);
            if (flag) {
                PartDO parentPartDO = this.getParentPart(partentPartXmlNode, childPartXmlNode, struct, basicListDTO, returnLogMap);
                PartMasterDO childPartMasterDO = this.getChildPartMaster(childPartXmlNode.getPartnumber(), basicListDTO, returnLogMap);
                boolean notUpdateBOM = false;
                if (this.notUpgradeVersion) {
                    List<PartUsageLinkDO> usageLinkDOS = (List)((List<PartUsageLinkDO>)partUsageLinkDOList).stream().filter((item) -> {
                        return parentPartDO.getOid().equals(item.getAoid());
                    }).collect(Collectors.toList());
                    if (CollUtil.isNotEmpty(usageLinkDOS)) {
                        notUpdateBOM = true;
                        log.info("您已开启配置项:【batchimport.partbom.history.not.upgrade.version】，当前零件【{}】在系统中已有BOM结构，本次导入将不再更新BOM！", partentPartXmlNode.getPartnumber());
                    }
                }

                if (!Objects.isNull(parentPartDO) && !Objects.isNull(childPartMasterDO) && !notUpdateBOM) {
                    if ("wrk".equalsIgnoreCase(parentPartDO.getLockstateinfo()) && !needDeleteParentOids.contains(parentPartDO.getOid())) {
                        needDeleteParentOids.add(parentPartDO.getOid());
                    }

                    PartUsageLinkDO partUsageLinkDO = this.typlmPartBomImportUtil.setPartUsageLink(parentPartDO, childPartMasterDO, struct, lineNumberMap, partImportToDBDTO);
                    this.typlmPartBomImportUtil.setPartUsageLinkUnit(partUsageLinkDO, basicListDTO, struct.getUnitkey(), childPartXmlNode.getDefaultunit());
                    this.typlmPartBomImportUtil.setPartUsageLinkType(basicListDTO, partUsageLinkDO);
                    PartImportIbaBeanDTO partImportIbaBeanDTO = this.typlmPartBomImportUtil.setEntityIbaInfo(basicListDTO, partUsageLinkDO, struct.getAttributes());
                    if (Objects.nonNull(partImportIbaBeanDTO)) {
                        partImportToDBDTO.getIbaBeanDTOInsertList().add(partImportIbaBeanDTO);
                    }

                    partImportToDBDTO.getSaveAsPartStructMap().put(struct.getSourceLinkOid(), partUsageLinkDO);
                    String pcnumber = "结构[父件" + partentPartXmlNode.getPartnumber() + "-" + "子件" + childPartXmlNode.getPartnumber() + "]";
                    this.typlmPartBomImportUtil.writeLogVo(pcnumber, "更新成功！", pcnumber + "更新成功！", "NORMAL", returnLogMap);
                }
            }
        }

        partImportToDBDTO.setNeedDeleteParentOids(needDeleteParentOids);
        TyplmLoggerUtil.debug(log, () -> {
            return "collectPartUsageLink ==> end collectPartUsageLink";
        });
    }

    private void upgradePart(PartXmlAllNodeDTO partXmlAllNodeDTO, TyPartImportBasicListDTO importBasicListDTO, PartImportToDBDTO partImportToDBDTO, UserDO userDO, Map<String, List<PartImportLogVO>> returnLogMap) {
        log.info("=====>>>> batchImportPartBom:begin upgradePart");
        if (this.notUpgradeVersion) {
            log.info("您已开启配置项:【batchimport.partbom.history.not.upgrade.version】，本次导入的零件将不会执行更新属性及升版操作！");
        } else {
            Map<String, PartDO> allAfterUpgradePartDOMap = new HashMap();
            Map<BigInteger, PartDO> upgradePartDOMap = importBasicListDTO.getUpgradePartDOMap();
            boolean isupdatePartAttr = true;
            boolean onlyCreateBuildRule = false;
            boolean isupdateBom;
            if ("true".equalsIgnoreCase(importBasicListDTO.getIsCadImport())) {
                isupdatePartAttr = importBasicListDTO.isUpdatePart();
                isupdateBom = importBasicListDTO.isUpdateBom();
                onlyCreateBuildRule = !isupdatePartAttr && !isupdateBom;
            }

            if ("false".equalsIgnoreCase(importBasicListDTO.getIsCadImport())) {
                isupdatePartAttr = importBasicListDTO.isUpdatePart();
                isupdateBom = importBasicListDTO.isUpdateBom();
                onlyCreateBuildRule = !isupdatePartAttr && !isupdateBom;
                if (onlyCreateBuildRule) {
                    return;
                }
            }

            log.info("=====>>>> batchImportPartBom:upgradePart=====>>>>upgradePartDOMap:" + upgradePartDOMap);
            Iterator var19 = upgradePartDOMap.entrySet().iterator();

            while(true) {
                while(var19.hasNext()) {
                    Map.Entry<BigInteger, PartDO> entry = (Map.Entry)var19.next();
                    PartMasterDO masterDo = this.typlmPartBomImportCheckUtil.getMasterDo(importBasicListDTO, (BigInteger)entry.getKey());
                    if (Objects.isNull(masterDo)) {
                        throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.SYS_ERROR_UNKNOW, new String[]{"masteredoid does not exist in upgradePartDOMap！"})));
                    }

                    PartXmlNodeDTO partXmlNodeDTO = (PartXmlNodeDTO)importBasicListDTO.getPartNumberMap().get(masterDo.getPartnumber());
                    PartDO sourcePartDO = (PartDO)entry.getValue();
                    if ("ref".equalsIgnoreCase(partXmlNodeDTO.getOptype())) {
                        this.typlmPartBomImportUtil.writeLogVo(partXmlNodeDTO.getPartnumber(), "忽略更新零件", PartBomErrorCodeEnum.BOM_IMPORT_PART_IS_BORROWED_IGNORING_UPDATE.getLocaleMessage(new Object[]{partXmlNodeDTO.getPartnumber()}), "ERROR", returnLogMap);
                    } else {
                        boolean isCreateBuildRule = true;
                        PartDO targetPartDO = this.copySourcePart(sourcePartDO, userDO);
                        if (onlyCreateBuildRule) {
                            isCreateBuildRule = this.createCadBuildRuleDTO(importBasicListDTO, partImportToDBDTO, targetPartDO, partXmlNodeDTO.getId(), partXmlNodeDTO.getPartnumber());
                        }

                        boolean upgradePart = !onlyCreateBuildRule || isCreateBuildRule || "dwgpart".equalsIgnoreCase(partXmlNodeDTO.getOptype());
                        if (upgradePart) {
                            this.updatePartAttr(partXmlAllNodeDTO, importBasicListDTO, partImportToDBDTO, isupdatePartAttr, partXmlNodeDTO, targetPartDO);
                            sourcePartDO.setPartnumber(partXmlNodeDTO.getPartnumber());
                            targetPartDO.setPartnumber(partXmlNodeDTO.getPartnumber());
                            partImportToDBDTO.getPartDOUpdateList().add(sourcePartDO);
                            partImportToDBDTO.getPartDOInsertList().add(targetPartDO);
                            this.setSourceAndTargetRel(partImportToDBDTO, partXmlNodeDTO, sourcePartDO, targetPartDO);
                            allAfterUpgradePartDOMap.put(masterDo.getPartnumber(), targetPartDO);
                            if (!onlyCreateBuildRule) {
                                this.createCadBuildRuleDTO(importBasicListDTO, partImportToDBDTO, targetPartDO, partXmlNodeDTO.getId(), partXmlNodeDTO.getPartnumber());
                            }

                            PartImportLogVO partImportLogVO = new PartImportLogVO();
                            partImportLogVO.setPartNumber(masterDo.getPartnumber());
                            partImportLogVO.setLogTitle("Parts upgraded successfully!");
                            partImportLogVO.setLogDetail(PartBomErrorCodeEnum.BOM_IMPORT_PART_UPGRADED_SUCCESSFULLY.getLocaleMessage(new Object[]{masterDo.getPartnumber()}));
                            partImportLogVO.setLogFlag("NORMAL");
                            partImportLogVO.setEvent("check_in");
                            partImportLogVO.setPartOid(targetPartDO.getOid().toString());
                            this.typlmPartBomImportUtil.writeLogVo(partImportLogVO, returnLogMap);
                        }
                    }
                }

                importBasicListDTO.setAllAfterUpgradePartDOMap(allAfterUpgradePartDOMap);
                log.info("=====>>>> batchImportPartBom:end upgradePart");
                return;
            }
        }
    }

    private void setSourceAndTargetRel(PartImportToDBDTO partImportToDBDTO, PartXmlNodeDTO partXmlNodeDTO, PartDO sourcePartDO, PartDO targetPartDO) {
        if ("dwgpart".equalsIgnoreCase(partXmlNodeDTO.getOptype())) {
            partImportToDBDTO.getSourceAndTargetPartRelCopyUsageLink().put(sourcePartDO, targetPartDO);
        } else {
            partImportToDBDTO.getSourceAndTargetPartRel().put(sourcePartDO, targetPartDO);
        }

    }

    private void updatePartAttr(PartXmlAllNodeDTO partXmlAllNodeDTO, TyPartImportBasicListDTO importBasicListDTO, PartImportToDBDTO partImportToDBDTO, boolean isupdatePartAttr, PartXmlNodeDTO partXmlNodeDTO, PartDO targetPartDO) {
        if (isupdatePartAttr) {
            targetPartDO.setDescription(partXmlNodeDTO.getRemark());
            this.typlmPartBomImportUtil.setPartEnumAttr(targetPartDO, partXmlNodeDTO, importBasicListDTO, true);
            PartImportIbaBeanDTO partImportIbaBeanDTO = this.typlmPartBomImportUtil.setEntityIbaInfo(importBasicListDTO, targetPartDO, partXmlNodeDTO.getAttributes());
            if (Objects.nonNull(partImportIbaBeanDTO)) {
                boolean containsColor = false;
                if (TyplmExcelDataCheckUtil.EXCLUSION_COLOR.contains(partXmlAllNodeDTO.getGlobe().getPartLinkType())) {
                    containsColor = partImportIbaBeanDTO.getIbas().stream().anyMatch((ibaDTO) -> {
                        return "NaturalColorIdentity".equals(ibaDTO.getKey()) || "ColorIdentity".equals(ibaDTO.getKey());
                    });
                }

                if (!containsColor) {
                    partImportToDBDTO.getIbaBeanDTOUpdateList().add(partImportIbaBeanDTO);
                }
            }
        }

    }

    private void batchQueryAndCheckData(UserDO userDO, TyPartImportBasicListDTO basicListDTO, PartXmlAllNodeDTO partXmlAllNodeDTO, Map<String, List<PartImportLogVO>> returnLogMap, List<Map<ResponseCodeEnum, String[]>> exceptions) {
        TyplmLoggerUtil.debug(log, () -> {
            return "batchQueryAndCheckData ==> begin batchQueryAndCheckData";
        });
        this.typlmPartBomImportCheckUtil.checkParamNull(basicListDTO, partXmlAllNodeDTO, exceptions);
        this.typlmPartBomImportCheckUtil.checkRefPartExist(partXmlAllNodeDTO.getPartList(), basicListDTO, exceptions);
        basicListDTO.getAllTypeQueryList().add("ty.inteplm.part.CTyPartUsageLink");
        Map<String, TypeDO> typeDOMap = this.batchQueryPartType(basicListDTO.getAllTypeQueryList(), exceptions);
        basicListDTO.setAllTypeDOMap(typeDOMap);
        this.typlmPartBomImportCheckUtil.batchQueryContainerByList(basicListDTO, partXmlAllNodeDTO, exceptions);
        this.buildClassificationInfo(basicListDTO, partXmlAllNodeDTO, typeDOMap, exceptions);
        if (!"true".equalsIgnoreCase(basicListDTO.getIsCadImport()) && !"saveAs".equalsIgnoreCase(basicListDTO.getIsCadImport())) {
            this.typlmPartBomImportCheckUtil.enumConstraintDisplayNameConversion(typeDOMap, partXmlAllNodeDTO, basicListDTO);
        }

        this.typlmPartBomImportCheckUtil.batchQueryFolderByList(basicListDTO, partXmlAllNodeDTO, exceptions);
        if (!"saveAs".equalsIgnoreCase(basicListDTO.getIsCadImport())) {
            this.typlmPartBomImportCheckUtil.batchQueryEnum(partXmlAllNodeDTO.getPartStruct(), basicListDTO, exceptions, partXmlAllNodeDTO);
        }

        this.typlmPartBomImportCheckUtil.queryTypeInitVersionAndLifeStage(basicListDTO, partXmlAllNodeDTO, exceptions);
        this.checkStructNumber(partXmlAllNodeDTO, exceptions);
        this.batchCheckObjRightNew(userDO, basicListDTO, returnLogMap, exceptions, partXmlAllNodeDTO);
        if (!Boolean.TRUE.equals(this.ignoreCheckCircularReference) && !"saveAs".equalsIgnoreCase(basicListDTO.getIsCadImport())) {
            this.typlmPartBomImportCheckUtil.checkPartViewAndCircularReference(partXmlAllNodeDTO.getPartStruct(), partXmlAllNodeDTO.getPartList(), basicListDTO);
        } else {
            TyplmLoggerUtil.debug(log, () -> {
                return "batchQueryAndCheckData ==> 跳过执行checkPartViewAndCircularReference校验!";
            });
        }

        TyplmLoggerUtil.debug(log, () -> {
            return "batchQueryAndCheckData ==> begin queryAttributeDOList";
        });
        Map<String, AttributeVO> attributeVOMap = this.typlmBatchImportBasicDataService.queryAttributeDOList(basicListDTO.getAllAttrKeyQueryList());
        basicListDTO.setAllAttributeVOMap(attributeVOMap);
        TyplmLoggerUtil.debug(log, () -> {
            return "batchQueryAndCheckData ==> end queryAttributeDOList";
        });
        TyplmLoggerUtil.debug(log, () -> {
            return "batchQueryAndCheckData ==> begin verificationDataAfterQueryPart";
        });
        this.typlmExecutePartImportExtensionUtil.verificationDataAfterQueryPart(userDO, basicListDTO, partXmlAllNodeDTO);
        TyplmLoggerUtil.debug(log, () -> {
            return "batchQueryAndCheckData ==> end verificationDataAfterQueryPart";
        });
    }

    private CTyEntityBaseDO getContainerEntity(PartXmlNodeDTO partXmlAllNodeDTO, TyPartImportBasicListDTO basicListDTO) {
        CTyEntityBaseDO cTyEntityBaseDO;
        if (StringUtils.isNotBlank(partXmlAllNodeDTO.getContaineroid())) {
            cTyEntityBaseDO = (CTyEntityBaseDO)basicListDTO.getAllContainerIdMap().get(new BigInteger(partXmlAllNodeDTO.getContaineroid()));
        } else {
            String containerName = partXmlAllNodeDTO.getContainername() + ":" + partXmlAllNodeDTO.getContainerotype();
            cTyEntityBaseDO = (CTyEntityBaseDO)basicListDTO.getAllContainerNameMap().get(containerName);
        }

        return cTyEntityBaseDO;
    }

    private List<TyplmClassificationEntityTreeVO> getClassificationEntityTreeVOList() {
        Optional<Object> optional = TyAccountContext.getBizCommonHolderMapValue("TyplmPartBomImportService:partClassificationTree");
        if (optional.isPresent()) {
            return (List)optional.get();
        } else {
            List<TyplmClassificationEntityTreeVO> result = this.typlmClassificationService.queryClassificationPathCodeByClassificationRoot(Collections.singletonList("ty.inteplm.part.CTyPart"));
            TyAccountContext.setBizCommonHolderMapValue("TyplmPartBomImportService:partClassificationTree", result);
            return result;
        }
    }

    private ImmutablePair<Map<String, TyplmClassificationEntityTreeVO>, Map<String, TyplmClassificationEntityTreeVO>> getClassificationTreeMap(List<TyplmClassificationEntityTreeVO> result) {
        if (CollectionUtils.isEmpty(result)) {
            return new ImmutablePair(Collections.emptyMap(), Collections.emptyMap());
        } else {
            Map<String, TyplmClassificationEntityTreeVO> displayNameMap = null;
            Map<String, TyplmClassificationEntityTreeVO> classpathMap = null;
            Optional<Object> displayNameMapOptional = TyAccountContext.getBizCommonHolderMapValue("TyplmPartBomImportService:partClassificationTree:displayNameMap");
            if (displayNameMapOptional.isPresent()) {
                displayNameMap = (Map)displayNameMapOptional.get();
            }

            Optional<Object> classPathMapOptional = TyAccountContext.getBizCommonHolderMapValue("TyplmPartBomImportService:partClassificationTree:classPathMap");
            if (classPathMapOptional.isPresent()) {
                classpathMap = (Map)classPathMapOptional.get();
            }

            boolean needDisplayNameMap = displayNameMap == null;
            boolean needClasspathMap = classpathMap == null;
            if (needDisplayNameMap || needClasspathMap) {
                if (needDisplayNameMap) {
                    displayNameMap = new HashMap();
                }

                if (needClasspathMap) {
                    classpathMap = new HashMap();
                }

                Iterator var8 = result.iterator();

                while(var8.hasNext()) {
                    TyplmClassificationEntityTreeVO vo = (TyplmClassificationEntityTreeVO)var8.next();
                    if (needDisplayNameMap) {
                        ((Map)displayNameMap).put(vo.getDisplayName(), vo);
                    }

                    if (needClasspathMap) {
                        ((Map)classpathMap).put(vo.getClasspath(), vo);
                    }
                }
            }

            if (needDisplayNameMap) {
                TyAccountContext.setBizCommonHolderMapValue("TyplmPartBomImportService:partClassificationTree:displayNameMap", displayNameMap);
            }

            if (needClasspathMap) {
                TyAccountContext.setBizCommonHolderMapValue("TyplmPartBomImportService:partClassificationTree:classPathMap", classpathMap);
            }

            return new ImmutablePair(displayNameMap, classpathMap);
        }
    }

    private void buildClassificationInfo(TyPartImportBasicListDTO importBasicListDTO, PartXmlAllNodeDTO partXmlAllNodeDTO, Map<String, TypeDO> typeDOMap, List<Map<ResponseCodeEnum, String[]>> exceptions) {
        String partLinkType = partXmlAllNodeDTO.getGlobe().getPartLinkType();
        List<TyplmClassificationEntityTreeVO> typlmClassificationEntityTreeVOList = this.getClassificationEntityTreeVOList();
        ImmutablePair<Map<String, TyplmClassificationEntityTreeVO>, Map<String, TyplmClassificationEntityTreeVO>> pair = this.getClassificationTreeMap(typlmClassificationEntityTreeVOList);
        Map<String, TyplmClassificationEntityTreeVO> displayNameMap = (Map)pair.getLeft();
        Map<String, TyplmClassificationEntityTreeVO> classpathMap = (Map)pair.getRight();
        Iterator var10 = partXmlAllNodeDTO.getPartList().iterator();

        while(true) {
            while(true) {
                PartXmlNodeDTO partXmlNodeDTO;
                String classification;
                do {
                    do {
                        if (!var10.hasNext()) {
                            return;
                        }

                        partXmlNodeDTO = (PartXmlNodeDTO)var10.next();
                        classification = partXmlNodeDTO.getPartclassification();
                    } while(StringUtils.isEmpty(classification));
                } while(!importBasicListDTO.getAllNewMasterNumberList().contains(partXmlNodeDTO.getPartnumber()));

                List<TyplmClassificationEntityTreeVO> classificationEntityTreeVOList = new ArrayList();
                TyplmClassificationEntityTreeVO voByDisplayName = (TyplmClassificationEntityTreeVO)displayNameMap.get(classification);
                TyplmClassificationEntityTreeVO voByClasspath = (TyplmClassificationEntityTreeVO)classpathMap.get(classification);
                if (voByDisplayName != null || voByClasspath != null) {
                    ((List)classificationEntityTreeVOList).add(voByDisplayName != null ? voByDisplayName : voByClasspath);
                }

                if (TyplmExcelDataCheckUtil.EXCLUSION_LIFECYCLE.contains(partLinkType) && CollUtil.isEmpty((Collection)classificationEntityTreeVOList)) {
                    TyplmExceptionUtil.addExceptions(ResponseCodeEnum.BOM_IMPORT_PART_CLASSIFICATION_NOT_EXIST, new String[]{partXmlNodeDTO.getPartnumber() + "," + partXmlNodeDTO.getPartname(), partXmlNodeDTO.getPartclassification()}, exceptions);
                } else {
                    if (((List)classificationEntityTreeVOList).size() > 1) {
                        CTyEntityBaseDO container = this.getContainerEntity(partXmlNodeDTO, importBasicListDTO);
                        TypeDO typeDO = (TypeDO)typeDOMap.get(partXmlNodeDTO.getParttypedefname());
                        TyplmBaseRuleBoundedObjDTO baseRuleBoundedObjInfo = new TyplmBaseRuleBoundedObjDTO();
                        if (Objects.nonNull(typeDO)) {
                            baseRuleBoundedObjInfo = this.typlmBasedRuleService.getBaseRuleBoundedObjInfo(typeDO.getOid(), container.getOid(), container.getOtype());
                        }

                        if (TyplmExcelDataCheckUtil.EXCLUSION_LIFECYCLE.contains(partLinkType) && (ObjectUtils.isEmpty(baseRuleBoundedObjInfo) || ObjectUtils.isEmpty(baseRuleBoundedObjInfo.getClassificationOid()))) {
                            TyplmExceptionUtil.addExceptions(ResponseCodeEnum.BOM_IMPORT_PART_CLASSIFICATION_UNIQUENESS_CANNOT_BE_DETERMINED, new String[]{partXmlNodeDTO.getPartnumber(), partXmlNodeDTO.getPartclassification()}, exceptions);
                            continue;
                        }

                        TyplmClassificationEntityDTO classificationEntityDTO = this.typlmClassificationService.queryClassificationByTypeAndName(baseRuleBoundedObjInfo.getClassificationType(), baseRuleBoundedObjInfo.getClassificationName());
                        String classBaseRuleDisplayName = !Objects.isNull(classificationEntityDTO) && !StringUtils.isBlank(classificationEntityDTO.getDisplayName()) ? classificationEntityDTO.getDisplayName() : baseRuleBoundedObjInfo.getClassificationName();
                        PartXmlNodeDTO finalPartXmlNodeDTO = partXmlNodeDTO;
                        classificationEntityTreeVOList = (List)typlmClassificationEntityTreeVOList.stream().filter((s) -> {
                            return s.getClasspath().contains(classBaseRuleDisplayName) && s.getClasspath().endsWith("/" + finalPartXmlNodeDTO.getPartclassification());
                        }).collect(Collectors.toList());
                        if (TyplmExcelDataCheckUtil.EXCLUSION_LIFECYCLE.contains(partLinkType) && (CollUtil.isEmpty((Collection)classificationEntityTreeVOList) || ((List)classificationEntityTreeVOList).size() > 1)) {
                            TyplmExceptionUtil.addExceptions(ResponseCodeEnum.BOM_IMPORT_PART_CLASSIFICATION_UNIQUENESS_CANNOT_BE_DETERMINED, new String[]{partXmlNodeDTO.getPartnumber(), partXmlNodeDTO.getPartclassification()}, exceptions);
                            continue;
                        }
                    }

                    if (CollUtil.isNotEmpty((Collection)classificationEntityTreeVOList)) {
                        TyplmClassificationEntityTreeVO typlmClassificationEntityTreeVO = (TyplmClassificationEntityTreeVO)((List)classificationEntityTreeVOList).get(0);
                        if (TyplmExcelDataCheckUtil.EXCLUSION_LIFECYCLE.contains(partLinkType) && TyplmEntityBaseUtil.judgeIntegerEquals(typlmClassificationEntityTreeVO.getInstantiable(), 0)) {
                            TyplmExceptionUtil.addExceptions(ResponseCodeEnum.BOM_IMPORT_PART_CLASSIFICATION_NOT_INSTANTIABLE, new String[]{partXmlNodeDTO.getPartnumber(), partXmlNodeDTO.getPartclassification()}, exceptions);
                        } else {
                            BigInteger oid = typlmClassificationEntityTreeVO.getOid();
                            if (Objects.nonNull(oid)) {
                                partXmlNodeDTO.setClassificationOid(oid.toString());
                            }
                        }
                    }
                }
            }
        }
    }

    public void batchCheckObjRightNew(UserDO userDO, TyPartImportBasicListDTO basicListDTO, Map<String, List<PartImportLogVO>> returnLogMap, List<Map<ResponseCodeEnum, String[]>> exceptions, PartXmlAllNodeDTO partXmlAllNodeDTO) {
        TyplmLoggerUtil.debug(log, () -> {
            return "batchCheckObjRightNew ==> begin batchCheckObjRight";
        });
        List<TyBaseObject> objects = new ArrayList();
        List<String> permissionList = new ArrayList();
        Map<String, String> oidTypeNumberMap = new HashMap();
        List<AccessJudgeDTO> accessJudgeList = this.collectObjForCheckRightNew(userDO, basicListDTO, objects, permissionList, oidTypeNumberMap, partXmlAllNodeDTO);
        if (!CollectionUtils.isEmpty(accessJudgeList)) {
            TyplmLoggerUtil.debug(log, () -> {
                return "入参 batchCheckObjRightNew accessJudgeList ==> 【{}】";
            }, () -> {
                return new Object[]{JSON.toJSONString(basicListDTO)};
            });
            List<TyException> tyExceptions = this.typlmPermissionsUtil.checkPolicyRightByBatchForException(accessJudgeList);
            Iterator var11 = tyExceptions.iterator();

            while(var11.hasNext()) {
                TyException tyException = (TyException)var11.next();
                if (!ObjectUtil.isEmpty(tyException) && !ObjectUtil.isEmpty(tyException.getResponseCodeEnum()) && !ObjectUtil.isEmpty(tyException.getObjects())) {
                    String localeMessage = tyException.getResponseCodeEnum().getLocaleMessage(tyException.getObjects());
                    if (StringUtils.isNotBlank(localeMessage)) {
                        TyplmExceptionUtil.addExceptions(ResponseCodeEnum.BATCH_SAVE_IBA_EXCEPTION, new String[]{localeMessage}, exceptions);
                    }
                }
            }

            TyplmLoggerUtil.debug(log, () -> {
                return "batchCheckObjRightNew tyExceptions 权限校验的异常结果，无异常代表有权限 ==> 【{}】";
            }, () -> {
                return new Object[]{JSON.toJSONString(tyExceptions)};
            });
        }

        if (EXCLUSION_CHANGE_NEW.contains(partXmlAllNodeDTO.getGlobe().getPartLinkType())) {
            this.collectPartForCheckUpdateRight(basicListDTO, returnLogMap, objects, permissionList, oidTypeNumberMap, partXmlAllNodeDTO);
        }

        boolean noModifyPartThrowFlag = false;
        if (partXmlAllNodeDTO.getGlobe() != null) {
            String isCadImport = partXmlAllNodeDTO.getGlobe().getIsCadImport();
            if (Boolean.TRUE.toString().equals(isCadImport) && this.cadThrowException) {
                noModifyPartThrowFlag = true;
            }
        }

        TyplmLoggerUtil.debug(log, () -> {
            return "batchCheckObjRightNew checkAccessByObjectId start =【{}】userid =【{}】permissions =【{}】 ";
        }, () -> {
            return new Object[]{JSON.toJSONString(objects), userDO.getOid(), JSON.toJSONString(permissionList)};
        });
        if (!CollectionUtils.isEmpty(objects)) {
            List<AccessBatchDTO> accessBatchDTOS = this.typlmAccessJudgeService.checkAccessByObjectId(objects, userDO, permissionList);
            TyplmLoggerUtil.debug(log, () -> {
                return "batchCheckObjRightNew checkAccessByObjectId end =【{}】";
            }, () -> {
                return new Object[]{JSON.toJSONString(accessBatchDTOS)};
            });
            if (!CollectionUtils.isEmpty(accessBatchDTOS)) {
                Map<BigInteger, PartDO> upgradePartDOMap = new HashMap();
                Map<String, PartDO> noModifyRightPartDOMap = new HashMap();
                List<String> noModifyRightPartList = new ArrayList();
                List<String> noReadRightPartList = new ArrayList();
                Iterator var16 = accessBatchDTOS.iterator();

                while(var16.hasNext()) {
                    AccessBatchDTO accessBatchDTO = (AccessBatchDTO)var16.next();
                    String oidOtype = accessBatchDTO.getObjectoid() + ":" + accessBatchDTO.getObjectotype();
                    if ("N".equalsIgnoreCase(accessBatchDTO.getIsAuthorized())) {
                        String code = "";
                        if (oidTypeNumberMap.containsKey(oidOtype)) {
                            code = (String)oidTypeNumberMap.get(oidOtype);
                        }

                        this.getNoRightParts(basicListDTO, partXmlAllNodeDTO, code, accessBatchDTO, noModifyRightPartList, noReadRightPartList, returnLogMap, exceptions);
                        this.getNoUpdateRightParts(noModifyRightPartDOMap, basicListDTO, accessBatchDTO, code, exceptions, noModifyPartThrowFlag);
                    } else {
                        this.getHasUpdateRightParts(upgradePartDOMap, basicListDTO, accessBatchDTO);
                    }
                }

                basicListDTO.setUpgradePartDOMap(upgradePartDOMap);
                TyplmLoggerUtil.debug(log, () -> {
                    return "batchCheckObjRightNew upgradePartDOMap ==> 【{}】";
                }, () -> {
                    return new Object[]{JSON.toJSONString(upgradePartDOMap)};
                });
                basicListDTO.setNoModifyRightPartList(noModifyRightPartList);
                TyplmLoggerUtil.debug(log, () -> {
                    return "batchCheckObjRightNew noModifyRightPartList ==> 【{}】";
                }, () -> {
                    return new Object[]{JSON.toJSONString(noModifyRightPartList)};
                });
                basicListDTO.setNoReadRightPartList(noReadRightPartList);
                TyplmLoggerUtil.debug(log, () -> {
                    return "batchCheckObjRightNew noReadRightPartList ==> 【{}】";
                }, () -> {
                    return new Object[]{JSON.toJSONString(noReadRightPartList)};
                });
                basicListDTO.setNoModifyRightPartDOMap(noModifyRightPartDOMap);
                TyplmLoggerUtil.debug(log, () -> {
                    return "batchCheckObjRightNew noModifyRightPartDOMap ==> 【{}】";
                }, () -> {
                    return new Object[]{JSON.toJSONString(noModifyRightPartDOMap)};
                });
            }
        }

        log.info("=====>>>> batchImportPartBom: end batchCheckObjRight");
    }

    private void getNoUpdateRightParts(Map<String, PartDO> noModifyPartDOMap, TyPartImportBasicListDTO basicListDTO, AccessBatchDTO accessBatchDTO, String code, List<Map<ResponseCodeEnum, String[]>> exceptions, boolean noModifyPartThrowFlag) {
        Map<BigInteger, PartDO> allUpdatePartDOMap = basicListDTO.getAllUpdatePartDOMap();
        allUpdatePartDOMap.keySet().forEach((masteroid) -> {
            PartDO partDO = (PartDO)allUpdatePartDOMap.get(masteroid);
            if (partDO.getOtype().equalsIgnoreCase(accessBatchDTO.getObjectotype()) && partDO.getOid().toString().equals(accessBatchDTO.getObjectoid())) {
                noModifyPartDOMap.put(code, partDO);
                if (noModifyPartThrowFlag) {
                    PartMasterDO masterDo = this.getMasterDo(basicListDTO, masteroid);
                    if (masterDo == null) {
                        return;
                    }

                    PartXmlNodeDTO partXmlNodeDTO = (PartXmlNodeDTO)basicListDTO.getPartNumberMap().get(masterDo.getPartnumber());
                    if (partXmlNodeDTO == null || "ref".equalsIgnoreCase(partXmlNodeDTO.getOptype())) {
                        return;
                    }

                    TyplmExceptionUtil.addExceptions(ResponseCodeEnum.BIZ_RIGHT_NO_MODIFY, "零部件:" + code, exceptions);
                }
            }

        });
    }

    private void getHasUpdateRightParts(Map<BigInteger, PartDO> upgradePartDOMap, TyPartImportBasicListDTO basicListDTO, AccessBatchDTO accessBatchDTO) {
        Map<BigInteger, PartDO> allUpdatePartDOMap = basicListDTO.getAllUpdatePartDOMap();
        allUpdatePartDOMap.keySet().forEach((masteroid) -> {
            PartDO partDO = (PartDO)allUpdatePartDOMap.get(masteroid);
            if (partDO.getOtype().equalsIgnoreCase(accessBatchDTO.getObjectotype()) && partDO.getOid().toString().equals(accessBatchDTO.getObjectoid()) && !"c/o".equalsIgnoreCase(partDO.getLockstateinfo())) {
                upgradePartDOMap.put(masteroid, partDO);
            }

        });
    }

    private void getNoRightParts(TyPartImportBasicListDTO basicListDTO, PartXmlAllNodeDTO partXmlAllNodeDTO, String name, AccessBatchDTO accessBatchDTO, List<String> noModifyRightPartList, List<String> noReadRightPartList, Map<String, List<PartImportLogVO>> returnLogMap, List<Map<ResponseCodeEnum, String[]>> exceptions) {
        if ("创建".equalsIgnoreCase(accessBatchDTO.getAccess())) {
            TyplmExceptionUtil.addExceptions(ResponseCodeEnum.BIZ_RIGHT_NO_CREATE, this.typlmPermissionsUtil.getTypeDisplayNameForAccess(accessBatchDTO.getObjectotype()), exceptions);
        } else if ("修改".equalsIgnoreCase(accessBatchDTO.getAccess()) && "ty.inteplm.part.CTyPart".equalsIgnoreCase(accessBatchDTO.getObjectotype())) {
            if (ObjectUtil.isNotEmpty(basicListDTO) && ObjectUtil.isNotEmpty(basicListDTO.getPartNumberMap())) {
                PartXmlNodeDTO partXmlNode = (PartXmlNodeDTO)basicListDTO.getPartNumberMap().get(name);
                if (ObjectUtil.isNotEmpty(partXmlNode) && "ref".equals(partXmlNode.getOptype())) {
                    return;
                }
            }

            this.typlmPartBomImportUtil.writeLogVo(name, "You do not have permission to modify parts", PartBomErrorCodeEnum.BOM_IMPORT_NOT_HAVE_MODIFY_PERMISSIONS.getLocaleMessage(new Object[]{name}), "ERROR", returnLogMap, "NO_ACCESS_RIGHT");
            this.addStringToList(name, noModifyRightPartList);
        } else if (accessBatchDTO.getAccess().contains("读取") && "ty.inteplm.part.CTyPart".equalsIgnoreCase(accessBatchDTO.getObjectotype())) {
            this.getNoReadRightParts(basicListDTO, partXmlAllNodeDTO, name, noModifyRightPartList, noReadRightPartList, returnLogMap, exceptions);
        } else {
            TyplmExceptionUtil.addExceptions(ResponseCodeEnum.BIZ_RIGHT_NO_MODIFY, "文件夹:" + name, exceptions);
        }

    }

    private void getNoReadRightParts(TyPartImportBasicListDTO basicListDTO, PartXmlAllNodeDTO partXmlAllNodeDTO, String name, List<String> noModifyRightPartList, List<String> noReadRightPartList, Map<String, List<PartImportLogVO>> returnLogMap, List<Map<ResponseCodeEnum, String[]>> exceptions) {
        PartXmlNodeDTO partXmlNode = (PartXmlNodeDTO)basicListDTO.getPartNumberMap().get(name);
        List<PartXmlStructNodeDTO> partStruct = partXmlAllNodeDTO.getPartStruct();
        List<String> allNewPart = this.getAllNewPart(basicListDTO);
        if (!partStruct.stream().noneMatch((item) -> {
            return item.getChildId().equals(partXmlNode.getId());
        }) || allNewPart.contains(partXmlNode.getPartnumber())) {
            Map<String, Object> noPartReadRightStop = this.typlmPreferenceValueUtil.readPreferenceValueByKeywords(Collections.singletonList("BatchImport_NoReadRightStop"));
            boolean noPartReadRightPart = BooleanUtils.toBooleanDefaultIfNull((Boolean)noPartReadRightStop.get("BatchImport_NoReadRightStop"), Boolean.TRUE);
            if (noPartReadRightPart) {
                TyplmExceptionUtil.addExceptions(ResponseCodeEnum.BIZ_RIGHT_NO_READ, "零部件:" + name, exceptions);
            } else {
                this.typlmPartBomImportUtil.writeLogVo(name, "You do not have permission to read parts", PartBomErrorCodeEnum.BOM_IMPORT_NOT_HAVE_READ_PERMISSIONS.getLocaleMessage(new Object[]{name}), "ERROR", returnLogMap);
                noReadRightPartList.add(name);
                this.addStringToList(name, noModifyRightPartList);
            }

        }
    }

    public PartMasterDO getMasterDo(TyPartImportBasicListDTO basicListDTO, BigInteger masteroid) {
        PartMasterDO partMasterDO = null;
        Collection<PartMasterDO> values = basicListDTO.getAllMasterDOMap().values();
        List<PartMasterDO> masterDOS = (List)values.stream().filter((master) -> {
            return masteroid.equals(master.getOid());
        }).collect(Collectors.toList());
        if (!CollectionUtils.isEmpty(masterDOS)) {
            partMasterDO = (PartMasterDO)masterDOS.get(0);
        }

        return partMasterDO;
    }

    private void collectPartForCheckUpdateRight(TyPartImportBasicListDTO basicListDTO, Map<String, List<PartImportLogVO>> returnLogMap, List<TyBaseObject> objects, List<String> permissionList, Map<String, String> oidTypeNumberMap, PartXmlAllNodeDTO partXmlAllNodeDTO) {
        Map<BigInteger, PartDO> allUpdatePartDOMap = basicListDTO.getAllUpdatePartDOMap();
        Map<String, PartDO> wrkPartDOMap = new HashMap();
        List<String> coPartList = new ArrayList();
        Map<String, String> partNumAndNameMap = new HashMap();
        if (ObjectUtil.isNotEmpty(partXmlAllNodeDTO)) {
            List<PartXmlNodeDTO> partList = partXmlAllNodeDTO.getPartList();
            Iterator var12 = partList.iterator();

            while(var12.hasNext()) {
                PartXmlNodeDTO partXmlNodeDTO = (PartXmlNodeDTO)var12.next();
                String partnumber = partXmlNodeDTO.getPartnumber();
                String partname = partXmlNodeDTO.getPartname();
                if (StringUtils.isNotBlank(partname) && StringUtils.isNotBlank(partnumber)) {
                    partNumAndNameMap.put(partnumber, partname);
                }
            }
        }

        if (!CollectionUtils.isEmpty(allUpdatePartDOMap)) {
            allUpdatePartDOMap.keySet().forEach((masteroid) -> {
                PartDO partDO = (PartDO)allUpdatePartDOMap.get(masteroid);
                PartMasterDO masterDo = this.getMasterDo(basicListDTO, masteroid);
                if (!Objects.isNull(masterDo)) {
                    if ("c/i".equalsIgnoreCase(partDO.getLockstateinfo())) {
                        objects.add(partDO);
                        permissionList.add("修改_读取");
                        oidTypeNumberMap.put(partDO.getOid() + ":" + partDO.getOtype(), masterDo.getPartnumber());
                    } else if ("c/o".equalsIgnoreCase(partDO.getLockstateinfo())) {
                        objects.add(partDO);
                        permissionList.add("读取");
                        oidTypeNumberMap.put(partDO.getOid() + ":" + partDO.getOtype(), masterDo.getPartnumber());
                        this.addStringToList(masterDo.getPartnumber(), coPartList);
                        this.typlmPartBomImportUtil.writeLogVo(masterDo.getPartnumber(), "part have been checked out by other users", PartBomErrorCodeEnum.BOM_IMPORT_OTHER_USERS_LOCKING.getLocaleMessage(new Object[]{masterDo.getPartnumber() + "," + (String)partNumAndNameMap.get(masterDo.getPartnumber())}), "ERROR", returnLogMap);
                    } else {
                        wrkPartDOMap.put(masterDo.getPartnumber(), partDO);
                    }

                }
            });
        }

        basicListDTO.setAllWrkPartDOMap(wrkPartDOMap);
        basicListDTO.setCoPartList(coPartList);
    }

    public void addStringToList(String name, List<String> stringList) {
        if (StringUtils.isNotEmpty(name) && !stringList.contains(name)) {
            stringList.add(name);
        }

    }

    public List<String> getAllNewPart(TyPartImportBasicListDTO basicListDTO) {
        List<String> numbers = new ArrayList();
        if (!CollectionUtils.isEmpty(basicListDTO.getAllNewMasterNumberList())) {
            numbers.addAll(basicListDTO.getAllNewMasterNumberList());
        }

        if (!CollectionUtils.isEmpty(basicListDTO.getAllNewPartViewNumberOidMap())) {
            numbers.addAll(basicListDTO.getAllNewPartViewNumberOidMap().keySet());
        }

        return numbers;
    }

    public CTyEntityBaseDO getFoldeEntityBase(String partnumber, TyPartImportBasicListDTO basicListDTO) {
        CTyEntityBaseDO cTyEntityBaseDO = null;
        PartXmlNodeDTO partXmlNodeDTO = (PartXmlNodeDTO)basicListDTO.getPartNumberMap().get(partnumber);
        if (StringUtils.isNotEmpty(partXmlNodeDTO.getSubfolderid())) {
            cTyEntityBaseDO = (CTyEntityBaseDO)basicListDTO.getAllBigIntegerSubfolderDOMap().get(new BigInteger(partXmlNodeDTO.getSubfolderid()));
        } else {
            Map<TyFolderPathDTO, CTyEntityBaseDO> pathBaseDOMap = basicListDTO.getAllPathDTOCTyEntityBaseDOMap();
            Iterator var6 = pathBaseDOMap.entrySet().iterator();

            while(var6.hasNext()) {
                Map.Entry<TyFolderPathDTO, CTyEntityBaseDO> pathdto = (Map.Entry)var6.next();
                String containerType = EntityBaseUtil.getContextTypeByContainerOtype(partXmlNodeDTO.getContainerotype());
                if (((TyFolderPathDTO)pathdto.getKey()).getContainerName().equalsIgnoreCase(partXmlNodeDTO.getContainername()) && ((TyFolderPathDTO)pathdto.getKey()).getContainerType().equalsIgnoreCase(containerType) && ((TyFolderPathDTO)pathdto.getKey()).getFolderPath().equalsIgnoreCase(partXmlNodeDTO.getSubfolderpath())) {
                    cTyEntityBaseDO = (CTyEntityBaseDO)pathdto.getValue();
                }
            }
        }

        if (Objects.isNull(cTyEntityBaseDO) && partXmlNodeDTO.getContaineroid() != null) {
            CTyEntityBaseDO containerDO = (CTyEntityBaseDO)basicListDTO.getAllContainerIdMap().get(new BigInteger(partXmlNodeDTO.getContaineroid()));
            if (ObjectUtil.isNotEmpty(containerDO)) {
                BigInteger defaultcabinetoid = ((ITyCabined)containerDO).getDefaultcabinetoid();
                cTyEntityBaseDO = (CTyEntityBaseDO)basicListDTO.getAllBigIntegerCabinetDOMap().get(defaultcabinetoid);
            }
        }

        return cTyEntityBaseDO;
    }

    private List<AccessJudgeDTO> collectObjForCheckRightNew(UserDO userDO, TyPartImportBasicListDTO basicListDTO, List<TyBaseObject> objects, List<String> permissionList, Map<String, String> oidTypeNumberMap, PartXmlAllNodeDTO partXmlAllNodeDTO) {
        TyplmLoggerUtil.debug(log, () -> {
            return "collectObjForCheckRightNew basicListDTO ==>";
        }, () -> {
            return new Object[]{basicListDTO};
        });
        List<String> numbers = this.getAllNewPart(basicListDTO);
        TyplmLoggerUtil.debug(log, () -> {
            return "collectObjForCheckRightNew getAllNewPart 所有要校验权限的零件编码 <==";
        }, () -> {
            return new Object[]{JSON.toJSONString(numbers)};
        });
        List<AccessJudgeDTO> checkObjCreateRight = new ArrayList();
        Set<String> typeDomainStateSet = new HashSet();
        Map<BigInteger, CTyEntityBaseDO> checkFolderRight = new HashMap();
        Map<String, TypeDO> allTypeDOMap = basicListDTO.getAllTypeDOMap();
        Set<BigInteger> typeOidSet = (Set)allTypeDOMap.values().stream().map(TypeDO::getOid).collect(Collectors.toSet());
        TyplmLoggerUtil.debug(log, () -> {
            return "collectObjForCheckRightNew typeOidSet 收集类型 <== 【{}】";
        }, () -> {
            return new Object[]{JSON.toJSONString(typeOidSet)};
        });
        Map<BigInteger, String> typeInthidMap = this.typlmTypeService.batchQueryInthidByOid(typeOidSet);
        TyplmLoggerUtil.debug(log, () -> {
            return "collectObjForCheckRightNew typeInthidMap 转化类型 <== 【{}】";
        }, () -> {
            return new Object[]{JSON.toJSONString(typeInthidMap)};
        });
        numbers.forEach((partnumber) -> {
            TyplmLoggerUtil.debug(log, () -> {
                return "collectObjForCheckRightNew numbers.forEach partnumber 零件编号 ==> 【{}】";
            }, () -> {
                return new Object[]{partnumber};
            });
            String parttype = ((PartXmlNodeDTO)basicListDTO.getPartNumberMap().get(partnumber)).getParttypedefname();
            TyplmLoggerUtil.debug(log, () -> {
                return "collectObjForCheckRightNew numbers.forEach parttype 零件类型 ==> 【{}】";
            }, () -> {
                return new Object[]{parttype};
            });
            TypeDO typeDO = (TypeDO)allTypeDOMap.get(parttype);
            CTyEntityBaseDO foldeEntityBase = this.getFoldeEntityBase(partnumber, basicListDTO);
            TyplmLoggerUtil.debug(log, () -> {
                return "collectObjForCheckRightNew numbers.forEach foldeEntityBase 文件夹数据 ==> 【{}】";
            }, () -> {
                return new Object[]{JSON.toJSONString(foldeEntityBase)};
            });
            BigInteger domainOid = null;
            if (foldeEntityBase instanceof ITyDomainAdministratored) {
                domainOid = ((ITyDomainAdministratored)foldeEntityBase).getDomainoid();
            }

            String domainOidStr = domainOid == null ? "" : domainOid.toString();
            PartTypeRelDTO typeRelDTO = (PartTypeRelDTO)basicListDTO.getNumberTypeRelDTOMap().get(partnumber);
            TyplmLoggerUtil.debug(log, () -> {
                return "collectObjForCheckRightNew numbers.forEach typeRelDTO 类型数据 ==> 【{}】";
            }, () -> {
                return new Object[]{JSON.toJSONString(typeRelDTO)};
            });
            String lifecycleStageKey = Objects.isNull(typeRelDTO) ? "" : typeRelDTO.getLifecyclestateKey();
            TyplmLoggerUtil.debug(log, () -> {
                return "collectObjForCheckRightNew numbers.forEach lifecycleStageKey 生命周期KEY ==> 【{}】";
            }, () -> {
                return new Object[]{lifecycleStageKey};
            });
            String typeDomainState = typeDO.getOid().toString() + ":" + domainOidStr + ":" + lifecycleStageKey;
            TyplmLoggerUtil.debug(log, () -> {
                return "collectObjForCheckRightNew numbers.forEach typeDomainState 类型域生命周期KEY ==> 【{}】";
            }, () -> {
                return new Object[]{typeDomainState};
            });
            if (EXCLUSION_CHANGE_NEW.contains(partXmlAllNodeDTO.getGlobe().getPartLinkType()) && !typeDomainStateSet.contains(typeDomainState)) {
                AccessJudgeDTO accessJudgeDTO = new AccessJudgeDTO();
                accessJudgeDTO.setDomainOid(domainOid);
                accessJudgeDTO.setLifecycleStageKey(lifecycleStageKey);
                accessJudgeDTO.setPermissionName("创建");
                accessJudgeDTO.setUserDO(userDO);
                String inthid = (String)typeInthidMap.get(typeDO.getOid());
                accessJudgeDTO.setObjType(inthid);
                typeDomainStateSet.add(typeDomainState);
                checkObjCreateRight.add(accessJudgeDTO);
            }

            if (foldeEntityBase != null && !checkFolderRight.containsKey(foldeEntityBase.getOid())) {
                checkFolderRight.put(foldeEntityBase.getOid(), foldeEntityBase);
                oidTypeNumberMap.put(foldeEntityBase.getOid() + ":" + foldeEntityBase.getOtype(), foldeEntityBase.getName());
            }

        });
        if (!CollectionUtils.isEmpty(checkFolderRight)) {
            Iterator var14 = checkFolderRight.entrySet().iterator();

            while(var14.hasNext()) {
                Map.Entry<BigInteger, CTyEntityBaseDO> entry = (Map.Entry)var14.next();
                objects.add(entry.getValue());
                permissionList.add("修改");
            }
        }

        return checkObjCreateRight;
    }
}
